-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathopenstackversion_controller_test.go
More file actions
1237 lines (1055 loc) · 53.7 KB
/
openstackversion_controller_test.go
File metadata and controls
1237 lines (1055 loc) · 53.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package functional_test
import (
"errors"
"os"
"strings"
. "github.com/onsi/ginkgo/v2" //revive:disable:dot-imports
. "github.com/onsi/gomega" //revive:disable:dot-imports
//revive:disable-next-line:dot-imports
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
. "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers"
corev1 "github.com/openstack-k8s-operators/openstack-operator/api/core/v1beta1"
dataplanev1 "github.com/openstack-k8s-operators/openstack-operator/api/dataplane/v1beta1"
k8s_corev1 "k8s.io/api/core/v1"
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
)
var _ = Describe("OpenStackOperator controller", func() {
BeforeEach(func() {
// lib-common uses OPERATOR_TEMPLATES env var to locate the "templates"
// directory of the operator. We need to set them othervise lib-common
// will fail to generate the ConfigMap as it does not find common.sh
err := os.Setenv("OPERATOR_TEMPLATES", "../../templates")
Expect(err).NotTo(HaveOccurred())
// create cluster config map which is used to validate if cluster supports fips
DeferCleanup(k8sClient.Delete, ctx, CreateClusterConfigCM())
})
When("A default OpenStackVersion instance is created with no Controlplane", func() {
BeforeEach(func() {
DeferCleanup(
th.DeleteInstance,
CreateOpenStackVersion(names.OpenStackVersionName, GetDefaultOpenStackVersionSpec()),
)
// Ensure that the version instance is not marked new any more
// to avoid racing between the below cleanup removing the finalizer
// and the controller adding the finalizer to the new instance.
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
// we remove the finalizer as this is needed without the Controlplane
DeferCleanup(
OpenStackVersionRemoveFinalizer,
ctx,
names.OpenStackVersionName,
)
})
It("should fail to create more than one OpenStackVersion", func() {
instance := &corev1.OpenStackVersion{}
instance.Namespace = names.Namespace
instance.Name = "foo"
err := k8sClient.Create(ctx, instance)
Expect(err).Should(HaveOccurred())
var statusError *k8s_errors.StatusError
Expect(errors.As(err, &statusError)).To(BeTrue())
Expect(statusError.ErrStatus.Details.Kind).To(Equal("OpenStackVersion"))
Expect(statusError.ErrStatus.Message).To(
ContainSubstring(
"Forbidden: Only one OpenStackVersion instance is supported at this time."),
)
})
It("should initialize container images", func() {
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(version).Should(Not(BeNil()))
// no condition which reflects an update is available
g.Expect(version.Status.Conditions.Has(corev1.OpenStackVersionMinorUpdateAvailable)).To(BeFalse())
g.Expect(*version.Status.AvailableVersion).Should(ContainSubstring("0.0.1"))
g.Expect(version.Spec.TargetVersion).Should(ContainSubstring("0.0.1"))
g.Expect(version.Status.ContainerImages.AgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.AnsibleeeImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.AodhAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.AodhEvaluatorImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.AodhListenerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.AodhNotifierImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.ApacheImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.BarbicanAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.BarbicanKeystoneListenerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.BarbicanWorkerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerCentralImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerComputeImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerNotificationImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerSgcoreImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerProxyImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CeilometerMysqldExporterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CinderAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CinderBackupImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.CinderSchedulerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateBackendbind9Image).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateCentralImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateMdnsImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateProducerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateUnboundImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.DesignateWorkerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmFrrImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmIscsidImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmLogrotateCrondImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmMultipathdImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmNeutronMetadataAgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmNeutronSriovAgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmNodeExporterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmKeplerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmPodmanExporterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OpenstackNetworkExporterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.EdpmOvnBgpAgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.GlanceAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.HeatAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.HeatCfnapiImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.HeatEngineImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.InfraDnsmasqImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.InfraMemcachedImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.InfraRedisImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicConductorImage).ShouldNot(BeNil())
//TODO(stevebaker) uncomment when these images are available
// g.Expect(version.Status.ContainerImages.IronicGraphicalConsoleImage).ShouldNot(BeNil())
// g.Expect(version.Status.ContainerImages.IronicNovncImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicInspectorImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicNeutronAgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicPxeImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.IronicPythonAgentImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.KeystoneAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.ManilaAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.ManilaSchedulerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.MariadbImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NetUtilsImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NeutronAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NovaAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NovaComputeImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NovaConductorImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NovaNovncImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.NovaSchedulerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaApacheImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaHealthmanagerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaHousekeepingImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaWorkerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OctaviaRsyslogImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OpenstackClientImage).ShouldNot(BeNil())
//fixme wire this one in
//g.Expect(version.Status.ContainerImages.OsContainerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OvnControllerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OvnControllerOvsImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OvnNbDbclusterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OvnNorthdImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.OvnSbDbclusterImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.PlacementAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.RabbitmqImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.SwiftAccountImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.SwiftContainerImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.SwiftObjectImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.SwiftProxyImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.TestTempestImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.TestTobikoImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.TestHorizontestImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.TestAnsibletestImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.WatcherAPIImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.WatcherDecisionEngineImage).ShouldNot(BeNil())
g.Expect(version.Status.ContainerImages.WatcherApplierImage).ShouldNot(BeNil())
}, timeout, interval).Should(Succeed())
})
})
// target version is *not* multiple OSVersion objects. Each time there is an update to a container image
// a new targetVersion is "discovered". This test is meant to simulate that environment
When("Multiple target versions exist", func() {
initialVersion := "old"
updatedVersion := "0.0.1"
targetOvnControllerVersion := ""
targetRabbitMQVersion := ""
targetMariaDBVersion := ""
targetMemcachedVersion := ""
targetKeystoneAPIVersion := ""
testOvnControllerImage := "foo/ovn:0.0.2"
testRabbitMQImage := "foo/rabbit:0.0.2"
testMariaDBImage := "foo/maria:0.0.2"
testMemcachedImage := "foo/memcached:0.0.2"
testKeystoneAPIImage := "foo/keystone:0.0.2"
// a lightweight controlplane spec we'll use for minor update testing
// we are missing some test helpers to simulate ready state so once we have
// we can go back to a more complete controlplane spec
BeforeEach(func() {
// this is a very "lightweight" controlplane for minimal
spec := GetDefaultOpenStackControlPlaneSpec()
// a single galera database
galeraTemplate := map[string]interface{}{
names.DBName.Name: map[string]interface{}{
"storageRequest": "500M",
},
}
spec["galera"] = map[string]interface{}{
"enabled": true,
"templates": galeraTemplate,
}
spec["horizon"] = map[string]interface{}{
"enabled": false,
}
spec["glance"] = map[string]interface{}{
"enabled": false,
}
spec["cinder"] = map[string]interface{}{
"enabled": false,
}
spec["neutron"] = map[string]interface{}{
"enabled": false,
}
spec["manila"] = map[string]interface{}{
"enabled": false,
}
spec["heat"] = map[string]interface{}{
"enabled": false,
}
spec["telemetry"] = map[string]interface{}{
"enabled": false,
}
spec["tls"] = GetTLSPublicSpec()
spec["ovn"] = map[string]interface{}{
"enabled": true,
"template": map[string]interface{}{
"ovnDBCluster": map[string]interface{}{
"ovndbcluster-nb": map[string]interface{}{
"dbType": "NB",
},
"ovndbcluster-sb": map[string]interface{}{
"dbType": "SB",
},
},
"ovnController": map[string]interface{}{
"nicMappings": map[string]interface{}{
"datacentre": "ospbr",
},
},
},
}
DeferCleanup(
th.DeleteInstance,
CreateOpenStackVersion(names.OpenStackVersionName, GetDefaultOpenStackVersionSpec()),
)
// create cert secrets for rabbitmq instances
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCertName))
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.RabbitMQCell1CertName))
// (mschuppert) create root CA secrets as there is no certmanager running.
// it is not used, just to make sure reconcile proceeds and creates the ca-bundle.
DeferCleanup(k8sClient.Delete, ctx, CreateCertSecret(names.RootCAPublicName))
DeferCleanup(k8sClient.Delete, ctx, CreateCertSecret(names.RootCAInternalName))
DeferCleanup(k8sClient.Delete, ctx, CreateCertSecret(names.RootCAOvnName))
DeferCleanup(k8sClient.Delete, ctx, CreateCertSecret(names.RootCALibvirtName))
// create cert secrets for galera instances
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.DBCertName))
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.DBCell1CertName))
// create cert secrets for memcached instance
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.MemcachedCertName))
// create cert secrets for ovn instance
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNNorthdCertName))
DeferCleanup(k8sClient.Delete, ctx, th.CreateCertSecret(names.OVNControllerCertName))
// wait for initial version to be created (this gives us version 0.0.1)
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
version := GetOpenStackVersion(names.OpenStackVersionName)
// capture this here as we'll need it below (this one comes from RELATED_IMAGES in hack/export_related_images.sh)
targetOvnControllerVersion = *version.Status.ContainerImages.OvnControllerImage
targetRabbitMQVersion = *version.Status.ContainerImages.RabbitmqImage
targetMariaDBVersion = *version.Status.ContainerImages.MariadbImage
targetMemcachedVersion = *version.Status.ContainerImages.InfraMemcachedImage
targetKeystoneAPIVersion = *version.Status.ContainerImages.KeystoneAPIImage
g.Expect(version).Should(Not(BeNil()))
g.Expect(*version.Status.AvailableVersion).Should(ContainSubstring("0.0.1"))
g.Expect(version.Spec.TargetVersion).Should(ContainSubstring("0.0.1"))
updatedVersion = *version.Status.AvailableVersion
}, timeout, interval).Should(Succeed())
// inject an "old" version
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Status.ContainerImageVersionDefaults[initialVersion] = version.Status.ContainerImageVersionDefaults[updatedVersion]
version.Status.ContainerImageVersionDefaults[initialVersion].OvnControllerImage = &testOvnControllerImage
version.Status.ContainerImageVersionDefaults[initialVersion].RabbitmqImage = &testRabbitMQImage
version.Status.ContainerImageVersionDefaults[initialVersion].MariadbImage = &testMariaDBImage
version.Status.ContainerImageVersionDefaults[initialVersion].InfraMemcachedImage = &testMemcachedImage
version.Status.ContainerImageVersionDefaults[initialVersion].KeystoneAPIImage = &testKeystoneAPIImage
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
th.Logger.Info("Version injected", "on", names.OpenStackVersionName)
}, timeout, interval).Should(Succeed())
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.TargetVersion = initialVersion
g.Expect(th.K8sClient.Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.Generation).Should(Equal(osversion.Status.ObservedGeneration))
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
g.Expect(*osversion.Status.AvailableVersion).Should(Equal(updatedVersion))
g.Expect(osversion.Spec.TargetVersion).Should(Equal(initialVersion))
g.Expect(osversion.Status.DeployedVersion).Should(BeNil())
// but the images should stay the same as we haven't switched to it yet
g.Expect(*osversion.Status.ContainerImages.OvnControllerImage).Should(Equal(testOvnControllerImage))
g.Expect(*osversion.Status.ContainerImages.RabbitmqImage).Should(Equal(testRabbitMQImage))
g.Expect(*osversion.Status.ContainerImages.MariadbImage).Should(Equal(testMariaDBImage))
g.Expect(*osversion.Status.ContainerImages.InfraMemcachedImage).Should(Equal(testMemcachedImage))
g.Expect(*osversion.Status.ContainerImages.KeystoneAPIImage).Should(Equal(testKeystoneAPIImage))
}, timeout, interval).Should(Succeed())
DeferCleanup(
th.DeleteInstance,
CreateOpenStackControlPlane(names.OpenStackControlplaneName, spec),
)
DeferCleanup(
th.DeleteInstance,
CreateDataplaneNodeSet(names.OpenStackVersionName, DefaultDataPlaneNoNodeSetSpec(false)),
)
dataplanenodeset := GetDataplaneNodeset(names.OpenStackVersionName)
dataplanenodeset.Status.DeployedVersion = initialVersion
Expect(th.K8sClient.Status().Update(th.Ctx, dataplanenodeset)).To(Succeed())
th.CreateSecret(types.NamespacedName{Name: "openstack-config-secret", Namespace: namespace}, map[string][]byte{"secure.yaml": []byte("foo")})
th.CreateConfigMap(types.NamespacedName{Name: "openstack-config", Namespace: namespace}, map[string]interface{}{"clouds.yaml": string("foo"), "OS_CLOUD": "default"})
// verify that the controlplane deploys the old OVN controller image
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
Expect(OSCtlplane.Spec.Ovn.Enabled).Should(BeTrue())
SimulateControlplaneReady()
// verify that DeployedVersion is set on the OpenStackControlplane to the initialversion
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackControlplaneName,
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
condition.ReadyCondition,
k8s_corev1.ConditionTrue,
)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
g.Expect(OSCtlplane.Status.DeployedVersion).Should(Equal(&initialVersion))
}, timeout, interval).Should(Succeed())
// verify DeployedVersion also gets set on the OpenStackVersion resource
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.Generation).Should(Equal(osversion.Status.ObservedGeneration))
g.Expect(osversion.Status.DeployedVersion).Should(Equal(&initialVersion))
}, timeout, interval).Should(Succeed())
})
// 1) bump the targetVersion to 0.0.1
// 2) verify that the OVN controller image gets updated on the controlplane
// 3) simulate the OVN controller image getting updated on the dataplane
// 4) verify that the rest of the container images get updated on the controlplane
// 5) simulate 1 more dataplanenodeset update to finish the minor update workflow
It("updating targetVersion triggers a minor update workflow", Serial, func() {
// 1) switch to version 0.0.1, this triggers a minor update
osversion := GetOpenStackVersion(names.OpenStackVersionName)
// should have a condition which reflects an update is available
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateAvailable,
k8s_corev1.ConditionTrue,
)
osversion.Spec.TargetVersion = updatedVersion
Expect(k8sClient.Update(ctx, osversion)).Should(Succeed())
// verify the OpenStackVersion gets re-initialized with 0.0.1 image for OVN
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.Generation).Should(Equal(osversion.Status.ObservedGeneration))
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
g.Expect(*osversion.Status.AvailableVersion).Should(Equal(updatedVersion))
g.Expect(osversion.Spec.TargetVersion).Should(Equal(updatedVersion))
// the target OVN Controller, RabbitMQ, MariaDB and KeystoneAPI image should be set on the Version object
g.Expect(*osversion.Status.ContainerImages.OvnControllerImage).Should(Equal(targetOvnControllerVersion))
g.Expect(*osversion.Status.ContainerImages.RabbitmqImage).Should(Equal(targetRabbitMQVersion))
g.Expect(*osversion.Status.ContainerImages.MariadbImage).Should(Equal(targetMariaDBVersion))
g.Expect(*osversion.Status.ContainerImages.InfraMemcachedImage).Should(Equal(targetMemcachedVersion))
g.Expect(*osversion.Status.ContainerImages.KeystoneAPIImage).Should(Equal(targetKeystoneAPIVersion))
}, timeout, interval).Should(Succeed())
// 2) now we check that the target OVN version gets set on the OVN Controller
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateOVNControlplane,
k8s_corev1.ConditionFalse,
)
ovn.SimulateOVNControllerReady(names.OVNControllerName)
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackControlplaneName,
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
corev1.OpenStackControlPlaneOVNReadyCondition,
k8s_corev1.ConditionTrue,
)
th.ExpectCondition(
names.OpenStackControlplaneName,
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
condition.ReadyCondition,
k8s_corev1.ConditionUnknown,
)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
// verify the image is set
g.Expect(*OSCtlplane.Status.ContainerImages.OvnControllerImage).Should(Equal(targetOvnControllerVersion))
}, timeout, interval).Should(Succeed())
// verify that OpenStackVersion is in the correct state (control plane OVN got updated)
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.OwnerReferences).Should(HaveLen(1))
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateOVNControlplane,
k8s_corev1.ConditionTrue,
)
}, timeout, interval).Should(Succeed())
// 3) simulate the OVN controller image getting updated on the dataplane
// NOTE: the real workflow here requires manual steps as well for now
dataplanenodeset := GetDataplaneNodeset(names.OpenStackVersionName)
dataplanenodeset.Status.ObservedGeneration = dataplanenodeset.Generation
dataplanenodeset.Status.ContainerImages = make(map[string]string)
dataplanenodeset.Status.ContainerImages["OvnControllerImage"] = targetOvnControllerVersion
dataplanenodeset.Status.Conditions.MarkTrue(condition.ReadyCondition, dataplanev1.NodeSetReadyMessage)
Expect(th.K8sClient.Status().Update(th.Ctx, dataplanenodeset)).To(Succeed())
// and now finally we verify that OpenStackVersion is in the correct state (data plane OVN got updated)
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.OwnerReferences).Should(HaveLen(1))
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateOVNDataplane,
k8s_corev1.ConditionTrue,
)
}, timeout, interval).Should(Succeed())
// 4a) RabbitMQ, first we wait for the condition to show up on the version resource
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateRabbitMQ,
k8s_corev1.ConditionFalse,
)
SimulateRabbitmqReady()
Eventually(func(g Gomega) {
// verify the rabbitmq minor update condition is set on the openstackversion object
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateRabbitMQ,
k8s_corev1.ConditionTrue,
)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
g.Expect(*OSCtlplane.Status.ContainerImages.RabbitmqImage).Should(Equal(targetRabbitMQVersion))
}, timeout*4, interval).Should(Succeed())
// 4b) Galera
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateMariaDB,
k8s_corev1.ConditionFalse,
)
SimulateGalaraReady()
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateMariaDB,
k8s_corev1.ConditionTrue,
)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
g.Expect(*OSCtlplane.Status.ContainerImages.MariadbImage).Should(Equal(targetMariaDBVersion))
}, timeout, interval).Should(Succeed())
// 4c) Memcached
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateMemcached,
k8s_corev1.ConditionFalse,
)
SimulateMemcachedReady()
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateMemcached,
k8s_corev1.ConditionTrue,
)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
g.Expect(*OSCtlplane.Status.ContainerImages.InfraMemcachedImage).Should(Equal(targetMemcachedVersion))
}, timeout, interval).Should(Succeed())
// 4d) Keystone
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateKeystone,
k8s_corev1.ConditionFalse,
)
keystone.SimulateKeystoneAPIReady(names.KeystoneAPIName)
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateKeystone,
k8s_corev1.ConditionTrue,
)
osversion := GetOpenStackVersion(names.OpenStackVersionName)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
g.Expect(OSCtlplane.Status.ContainerImages.KeystoneAPIImage).Should(Equal(osversion.Status.ContainerImages.KeystoneAPIImage))
}, timeout, interval).Should(Succeed())
// 4d) verify that the rest of the container images get updated on the controlplane
// this would occur automatically via the watch on the DataPlaneNodeSet's by openstackcontrolplane
// so once the administrator executes the DataplaneDeployment and that finishes the controlplane will update the images immediately
SimulateControlplaneReady()
// now we check that the container images for the aforementioned services got updated
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionMinorUpdateControlplane,
k8s_corev1.ConditionTrue,
)
th.ExpectCondition(
names.OpenStackControlplaneName,
ConditionGetterFunc(OpenStackControlPlaneConditionGetter),
condition.ReadyCondition,
k8s_corev1.ConditionTrue,
)
osversion := GetOpenStackVersion(names.OpenStackVersionName)
OSCtlplane := GetOpenStackControlPlane(names.OpenStackControlplaneName)
// verify images match for deployed services on the controlplane
g.Expect(OSCtlplane.Status.ContainerImages.RabbitmqImage).Should(Equal(osversion.Status.ContainerImages.RabbitmqImage))
g.Expect(OSCtlplane.Status.ContainerImages.MariadbImage).Should(Equal(osversion.Status.ContainerImages.MariadbImage))
g.Expect(OSCtlplane.Status.ContainerImages.KeystoneAPIImage).Should(Equal(osversion.Status.ContainerImages.KeystoneAPIImage))
g.Expect(OSCtlplane.Status.ContainerImages.InfraMemcachedImage).Should(Equal(osversion.Status.ContainerImages.InfraMemcachedImage))
g.Expect(OSCtlplane.Status.ContainerImages.OvnControllerImage).Should(Equal(osversion.Status.ContainerImages.OvnControllerImage))
g.Expect(OSCtlplane.Status.ContainerImages.OvnControllerOvsImage).Should(Equal(osversion.Status.ContainerImages.OvnControllerOvsImage))
g.Expect(OSCtlplane.Status.ContainerImages.OvnNbDbclusterImage).Should(Equal(osversion.Status.ContainerImages.OvnNbDbclusterImage))
g.Expect(OSCtlplane.Status.ContainerImages.OvnNorthdImage).Should(Equal(osversion.Status.ContainerImages.OvnNorthdImage))
g.Expect(OSCtlplane.Status.ContainerImages.OvnSbDbclusterImage).Should(Equal(osversion.Status.ContainerImages.OvnSbDbclusterImage))
}, timeout, interval).Should(Succeed())
// 5) simulate 1 more dataplanenodeset update to finish the minor update workflow
// NOTE: the real workflow here requires manual intervention as well for now
dataplanenodeset = GetDataplaneNodeset(names.OpenStackVersionName)
dataplanenodeset.Status.ObservedGeneration = dataplanenodeset.Generation
dataplanenodeset.Status.DeployedVersion = osversion.Spec.TargetVersion
dataplanenodeset.Status.Conditions.MarkTrue(condition.ReadyCondition, dataplanev1.NodeSetReadyMessage)
Expect(th.K8sClient.Status().Update(th.Ctx, dataplanenodeset)).To(Succeed())
// and now finally we verify that OpenStackVersion is in the correct state (data plane conditions, etc)
Eventually(func(g Gomega) {
osversion := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(osversion).Should(Not(BeNil()))
g.Expect(osversion.OwnerReferences).Should(HaveLen(1))
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
condition.ReadyCondition,
k8s_corev1.ConditionTrue,
)
g.Expect(osversion.Status.DeployedVersion).Should(Equal(&updatedVersion)) // we're done here
// no condition which reflects an update is available
g.Expect(osversion.Status.Conditions.Has(corev1.OpenStackVersionMinorUpdateAvailable)).To(BeFalse())
}, timeout, interval).Should(Succeed())
})
})
When("CustomContainerImages are set", func() {
var (
initialVersion = "0.0.1"
updatedVersion = "0.0.2"
)
When("KeystoneAPI custom images", func() {
var customKeystoneImage = "custom.registry/keystone:custom-tag"
BeforeEach(func() {
// Create OpenStackVersion with custom container images
spec := GetDefaultOpenStackVersionSpec()
spec["customContainerImages"] = map[string]interface{}{
"keystoneAPIImage": customKeystoneImage,
}
DeferCleanup(
th.DeleteInstance,
CreateOpenStackVersion(names.OpenStackVersionName, spec),
)
// Wait for initial version to be created and initialized
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
version := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(version).Should(Not(BeNil()))
g.Expect(*version.Status.AvailableVersion).Should(ContainSubstring(initialVersion))
g.Expect(version.Spec.TargetVersion).Should(ContainSubstring(initialVersion))
}, timeout, interval).Should(Succeed())
// Inject a newer version for testing minor updates
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
// Create container defaults for the updated version
if version.Status.ContainerImageVersionDefaults == nil {
version.Status.ContainerImageVersionDefaults = make(map[string]*corev1.ContainerDefaults)
}
version.Status.ContainerImageVersionDefaults[updatedVersion] = &corev1.ContainerDefaults{
ContainerTemplate: corev1.ContainerTemplate{
KeystoneAPIImage: &customKeystoneImage,
},
}
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Simulate deployment by setting DeployedVersion
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Status.DeployedVersion = &initialVersion
// Track the custom images for the initial version
if version.Status.TrackedCustomImages == nil {
version.Status.TrackedCustomImages = make(map[string]corev1.CustomContainerImages)
}
version.Status.TrackedCustomImages[initialVersion] = corev1.CustomContainerImages{
ContainerTemplate: corev1.ContainerTemplate{
KeystoneAPIImage: &customKeystoneImage,
},
}
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Remove finalizer as needed for cleanup
DeferCleanup(
OpenStackVersionRemoveFinalizer,
ctx,
names.OpenStackVersionName,
)
})
It("should prevent targetVersion modification when CustomContainerImages are unchanged", func() {
// Attempt to update targetVersion without changing CustomContainerImages
// This should be rejected by the webhook validation
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
// Try to update to the new version without changing custom images
version.Spec.TargetVersion = updatedVersion
// Keep the same custom container images (this should trigger validation error)
version.Spec.CustomContainerImages = corev1.CustomContainerImages{
ContainerTemplate: corev1.ContainerTemplate{
KeystoneAPIImage: &customKeystoneImage,
},
}
err := k8sClient.Update(ctx, version)
g.Expect(err).Should(HaveOccurred())
g.Expect(err.Error()).Should(ContainSubstring("CustomContainerImages must be updated when changing targetVersion"))
g.Expect(err.Error()).Should(ContainSubstring("prevents proper version tracking and validation"))
}, timeout, interval).Should(Succeed())
})
It("should allow targetVersion modification when CustomContainerImages are updated", func() {
// Update CustomContainerImages along with targetVersion
newCustomKeystoneImage := "custom.registry/keystone:new-custom-tag"
// Use Eventually to handle potential conflicts from controller updates
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.TargetVersion = updatedVersion
// Update the custom container images (this should be allowed)
version.Spec.CustomContainerImages = corev1.CustomContainerImages{
ContainerTemplate: corev1.ContainerTemplate{
KeystoneAPIImage: &newCustomKeystoneImage,
},
}
g.Expect(k8sClient.Update(ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Verify the update was successful
Eventually(func(g Gomega) {
updatedVersionObj := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(updatedVersionObj.Spec.TargetVersion).Should(Equal(updatedVersion))
g.Expect(*updatedVersionObj.Spec.CustomContainerImages.KeystoneAPIImage).Should(Equal(newCustomKeystoneImage))
}, timeout, interval).Should(Succeed())
})
It("should allow targetVersion modification when no CustomContainerImages are set", func() {
// First, remove custom container images
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.CustomContainerImages = corev1.CustomContainerImages{}
g.Expect(k8sClient.Update(ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Now update targetVersion (this should be allowed since no custom images)
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.TargetVersion = updatedVersion
g.Expect(k8sClient.Update(ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Verify the update was successful
Eventually(func(g Gomega) {
versionObj := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(versionObj.Spec.TargetVersion).Should(Equal(updatedVersion))
}, timeout, interval).Should(Succeed())
})
})
When("CinderVolume custom images", func() {
var customCinderVolumeImage = "custom.registry/cinder-volume:custom-tag"
BeforeEach(func() {
// Create OpenStackVersion with custom CinderVolumeImages
spec := GetDefaultOpenStackVersionSpec()
spec["customContainerImages"] = map[string]interface{}{
"cinderVolumeImages": map[string]string{
"backend1": customCinderVolumeImage,
},
}
DeferCleanup(
th.DeleteInstance,
CreateOpenStackVersion(names.OpenStackVersionName, spec),
)
// Wait for initial version to be created and initialized
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
version := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(version).Should(Not(BeNil()))
g.Expect(*version.Status.AvailableVersion).Should(ContainSubstring(initialVersion))
g.Expect(version.Spec.TargetVersion).Should(ContainSubstring(initialVersion))
}, timeout, interval).Should(Succeed())
// Inject a newer version for testing minor updates
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
// Create container defaults for the updated version
if version.Status.ContainerImageVersionDefaults == nil {
version.Status.ContainerImageVersionDefaults = make(map[string]*corev1.ContainerDefaults)
}
version.Status.ContainerImageVersionDefaults[updatedVersion] = &corev1.ContainerDefaults{}
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Simulate deployment by setting DeployedVersion
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Status.DeployedVersion = &initialVersion
// Track the custom images for the initial version
if version.Status.TrackedCustomImages == nil {
version.Status.TrackedCustomImages = make(map[string]corev1.CustomContainerImages)
}
version.Status.TrackedCustomImages[initialVersion] = corev1.CustomContainerImages{
CinderVolumeImages: map[string]*string{
"backend1": &customCinderVolumeImage,
},
}
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Remove finalizer as needed for cleanup
DeferCleanup(
OpenStackVersionRemoveFinalizer,
ctx,
names.OpenStackVersionName,
)
})
It("should prevent targetVersion modification when CinderVolumeImages are unchanged", func() {
// Attempt to update targetVersion without changing CinderVolumeImages
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.TargetVersion = updatedVersion
// Keep the same CinderVolumeImages (this should trigger validation error)
version.Spec.CustomContainerImages = corev1.CustomContainerImages{
CinderVolumeImages: map[string]*string{
"backend1": &customCinderVolumeImage,
},
}
err := k8sClient.Update(ctx, version)
if err != nil && strings.Contains(err.Error(), "the object has been modified") {
// Retry on conflict errors
return
}
g.Expect(err).Should(HaveOccurred())
g.Expect(err.Error()).Should(ContainSubstring("CustomContainerImages must be updated when changing targetVersion"))
}, timeout, interval).Should(Succeed())
})
It("should allow targetVersion modification when CinderVolumeImages are updated", func() {
newCustomCinderVolumeImage := "custom.registry/cinder-volume:new-custom-tag"
// Update CinderVolumeImages along with targetVersion
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
version.Spec.TargetVersion = updatedVersion
// Update the CinderVolumeImages (this should be allowed)
version.Spec.CustomContainerImages = corev1.CustomContainerImages{
CinderVolumeImages: map[string]*string{
"backend1": &newCustomCinderVolumeImage,
},
}
g.Expect(k8sClient.Update(ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Verify the update was successful
Eventually(func(g Gomega) {
updatedVersionObj := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(updatedVersionObj.Spec.TargetVersion).Should(Equal(updatedVersion))
g.Expect(*updatedVersionObj.Spec.CustomContainerImages.CinderVolumeImages["backend1"]).Should(Equal(newCustomCinderVolumeImage))
}, timeout, interval).Should(Succeed())
})
})
When("ManilaShare custom images", func() {
var customManilaShareImage = "custom.registry/manila-share:custom-tag"
BeforeEach(func() {
// Create OpenStackVersion with custom ManilaShareImages
spec := GetDefaultOpenStackVersionSpec()
spec["customContainerImages"] = map[string]interface{}{
"manilaShareImages": map[string]string{
"share-backend1": customManilaShareImage,
},
}
DeferCleanup(
th.DeleteInstance,
CreateOpenStackVersion(names.OpenStackVersionName, spec),
)
// Wait for initial version to be created and initialized
Eventually(func(g Gomega) {
th.ExpectCondition(
names.OpenStackVersionName,
ConditionGetterFunc(OpenStackVersionConditionGetter),
corev1.OpenStackVersionInitialized,
k8s_corev1.ConditionTrue,
)
version := GetOpenStackVersion(names.OpenStackVersionName)
g.Expect(version).Should(Not(BeNil()))
g.Expect(*version.Status.AvailableVersion).Should(ContainSubstring(initialVersion))
g.Expect(version.Spec.TargetVersion).Should(ContainSubstring(initialVersion))
}, timeout, interval).Should(Succeed())
// Inject a newer version for testing minor updates
Eventually(func(g Gomega) {
version := GetOpenStackVersion(names.OpenStackVersionName)
// Create container defaults for the updated version
if version.Status.ContainerImageVersionDefaults == nil {
version.Status.ContainerImageVersionDefaults = make(map[string]*corev1.ContainerDefaults)
}
version.Status.ContainerImageVersionDefaults[updatedVersion] = &corev1.ContainerDefaults{}
g.Expect(th.K8sClient.Status().Update(th.Ctx, version)).To(Succeed())
}, timeout, interval).Should(Succeed())
// Simulate deployment by setting DeployedVersion
Eventually(func(g Gomega) {