@@ -82,15 +82,15 @@ var _ = Describe("CRD Versions", func() {
82
82
},
83
83
}
84
84
85
- // Create the catalog sources
85
+ By ( " Create the catalog sources" )
86
86
_ , cleanupMainCatalogSource := createV1CRDInternalCatalogSource (GinkgoT (), c , crc , mainCatalogName , generatedNamespace .GetName (), mainManifests , []apiextensionsv1.CustomResourceDefinition {v1crd }, []operatorsv1alpha1.ClusterServiceVersion {mainCSV })
87
87
defer cleanupMainCatalogSource ()
88
88
defer func () {
89
89
_ = crc .OperatorsV1alpha1 ().ClusterServiceVersions (generatedNamespace .GetName ()).Delete (context .TODO (), mainCSV .GetName (), metav1.DeleteOptions {})
90
90
_ = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Delete (context .TODO (), v1crd .GetName (), metav1.DeleteOptions {})
91
91
}()
92
92
93
- // Attempt to get the catalog source before creating install plan
93
+ By ( " Attempt to get the catalog source before creating install plan" )
94
94
95
95
_ , err := fetchCatalogSourceOnStatus (crc , mainCatalogName , generatedNamespace .GetName (), catalogSourceRegistryPodSynced ())
96
96
Expect (err ).ToNot (HaveOccurred ())
@@ -107,7 +107,7 @@ var _ = Describe("CRD Versions", func() {
107
107
108
108
installPlanName := subscription .Status .InstallPlanRef .Name
109
109
110
- // Wait for InstallPlan to be status: Complete before checking resource presence
110
+ By ( " Wait for InstallPlan to be status: Complete before checking resource presence" )
111
111
fetchedInstallPlan , err := fetchInstallPlan (GinkgoT (), crc , installPlanName , generatedNamespace .GetName (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
112
112
Expect (err ).ToNot (HaveOccurred ())
113
113
GinkgoT ().Logf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase )
@@ -220,7 +220,7 @@ var _ = Describe("CRD Versions", func() {
220
220
},
221
221
}
222
222
223
- // Create the catalog sources
223
+ By ( " Create the catalog sources" )
224
224
_ , cleanupMainCatalogSource := createInternalCatalogSource (c , crc , mainCatalogName , generatedNamespace .GetName (), mainManifests , []apiextensionsv1.CustomResourceDefinition {oldCRD , newCRD }, []operatorsv1alpha1.ClusterServiceVersion {oldCSV , newCSV })
225
225
defer cleanupMainCatalogSource ()
226
226
defer func () {
@@ -230,7 +230,7 @@ var _ = Describe("CRD Versions", func() {
230
230
_ = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Delete (context .TODO (), newCRD .GetName (), metav1.DeleteOptions {})
231
231
}()
232
232
233
- // Attempt to get the catalog source before creating install plan
233
+ By ( " Attempt to get the catalog source before creating install plan" )
234
234
_ , err := fetchCatalogSourceOnStatus (crc , mainCatalogName , generatedNamespace .GetName (), catalogSourceRegistryPodSynced ())
235
235
Expect (err ).ToNot (HaveOccurred ())
236
236
@@ -246,15 +246,15 @@ var _ = Describe("CRD Versions", func() {
246
246
247
247
installPlanName := subscription .Status .InstallPlanRef .Name
248
248
249
- // Wait for InstallPlan to be status: Complete before checking resource presence
249
+ By ( " Wait for InstallPlan to be status: Complete before checking resource presence" )
250
250
fetchedInstallPlan , err := fetchInstallPlan (GinkgoT (), crc , installPlanName , generatedNamespace .GetName (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
251
251
Expect (err ).ToNot (HaveOccurred ())
252
252
GinkgoT ().Logf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase )
253
253
Expect (fetchedInstallPlan .Status .Phase ).To (Equal (operatorsv1alpha1 .InstallPlanPhaseComplete ))
254
254
255
- // old CRD has been installed onto the cluster - now upgrade the subscription to point to the channel with the new CRD
256
- // installing the new CSV should fail with a warning about data loss, since a storage version is missing in the new CRD
257
- // use server-side apply to apply the update to the subscription point to the alpha channel
255
+ By ( " old CRD has been installed onto the cluster - now upgrade the subscription to point to the channel with the new CRD" )
256
+ By ( " installing the new CSV should fail with a warning about data loss, since a storage version is missing in the new CRD" )
257
+ By ( " use server-side apply to apply the update to the subscription point to the alpha channel" )
258
258
Eventually (Apply (subscription , func (s * operatorsv1alpha1.Subscription ) error {
259
259
s .Spec .Channel = alphaChannel
260
260
return nil
@@ -266,13 +266,13 @@ var _ = Describe("CRD Versions", func() {
266
266
return checker (v ) && v .Status .InstallPlanRef != nil && v .Status .InstallPlanRef .Name != fetchedInstallPlan .Name
267
267
}
268
268
269
- // fetch new subscription
269
+ By ( " fetch new subscription" )
270
270
s , err := fetchSubscription (crc , generatedNamespace .GetName (), subscriptionName , subscriptionAtLatestWithDifferentInstallPlan )
271
271
Expect (err ).ToNot (HaveOccurred ())
272
272
Expect (s ).ToNot (BeNil ())
273
273
Expect (s .Status .InstallPlanRef ).ToNot (Equal (nil ))
274
274
275
- // Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version
275
+ By ( " Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version" )
276
276
Eventually (func () (* operatorsv1alpha1.InstallPlan , error ) {
277
277
return crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Get (context .TODO (), s .Status .InstallPlanRef .Name , metav1.GetOptions {})
278
278
}).Should (And (
@@ -291,15 +291,15 @@ var _ = Describe("CRD Versions", func() {
291
291
))
292
292
})
293
293
294
- // Create a CRD on cluster with v1alpha1 (storage)
295
- // Update that CRD with v1alpha2 (storage), v1alpha1 (served)
296
- // Now the CRD should have two versions in status.storedVersions
297
- // Now make a catalog with a CRD with just v1alpha2 (storage)
298
- // That should fail because v1alpha1 is still in status.storedVersions - risk of data loss
299
- // Update the CRD status to remove the v1alpha1
300
- // Now the installplan should succeed
301
-
302
294
It ("allows a CRD upgrade that doesn't cause data loss" , func () {
295
+ By (`Create a CRD on cluster with v1alpha1 (storage)` )
296
+ By (`Update that CRD with v1alpha2 (storage), v1alpha1 (served)` )
297
+ By (`Now the CRD should have two versions in status.storedVersions` )
298
+ By (`Now make a catalog with a CRD with just v1alpha2 (storage)` )
299
+ By (`That should fail because v1alpha1 is still in status.storedVersions - risk of data loss` )
300
+ By (`Update the CRD status to remove the v1alpha1` )
301
+ By (`Now the installplan should succeed` )
302
+
303
303
By ("manually editing the storage versions in the existing CRD status" )
304
304
305
305
crdPlural := genName ("ins-v1-" )
@@ -337,17 +337,17 @@ var _ = Describe("CRD Versions", func() {
337
337
_ , err := c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Create (context .TODO (), oldCRD , metav1.CreateOptions {})
338
338
Expect (err ).ToNot (HaveOccurred (), "error creating old CRD" )
339
339
340
- // wrap CRD update in a poll because of the object has been modified related errors
340
+ By ( " wrap CRD update in a poll because of the object has been modified related errors" )
341
341
Eventually (func () error {
342
342
oldCRD , err = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
343
343
if err != nil {
344
344
return err
345
345
}
346
346
GinkgoT ().Logf ("old crd status stored versions: %#v" , oldCRD .Status .StoredVersions )
347
347
348
- // set v1alpha1 to no longer stored
348
+ By ( " set v1alpha1 to no longer stored" )
349
349
oldCRD .Spec .Versions [0 ].Storage = false
350
- // update CRD on-cluster with a new version
350
+ By ( " update CRD on-cluster with a new version" )
351
351
oldCRD .Spec .Versions = append (oldCRD .Spec .Versions , apiextensionsv1.CustomResourceDefinitionVersion {
352
352
Name : "v1alpha2" ,
353
353
Served : true ,
@@ -367,7 +367,7 @@ var _ = Describe("CRD Versions", func() {
367
367
return nil
368
368
}).Should (BeNil ())
369
369
370
- // create CSV and catalog with just the catalog CRD
370
+ By ( " create CSV and catalog with just the catalog CRD" )
371
371
catalogCRD := apiextensionsv1.CustomResourceDefinition {
372
372
ObjectMeta : metav1.ObjectMeta {
373
373
Name : crdName ,
@@ -417,11 +417,11 @@ var _ = Describe("CRD Versions", func() {
417
417
},
418
418
}
419
419
420
- // Create the catalog sources
420
+ By ( " Create the catalog sources" )
421
421
_ , cleanupMainCatalogSource := createInternalCatalogSource (c , crc , mainCatalogName , generatedNamespace .GetName (), mainManifests , []apiextensionsv1.CustomResourceDefinition {catalogCRD }, []operatorsv1alpha1.ClusterServiceVersion {catalogCSV })
422
422
defer cleanupMainCatalogSource ()
423
423
424
- // Attempt to get the catalog source before creating install plan
424
+ By ( " Attempt to get the catalog source before creating install plan" )
425
425
_ , err = fetchCatalogSourceOnStatus (crc , mainCatalogName , generatedNamespace .GetName (), catalogSourceRegistryPodSynced ())
426
426
Expect (err ).ToNot (HaveOccurred ())
427
427
@@ -434,7 +434,7 @@ var _ = Describe("CRD Versions", func() {
434
434
Expect (subscription .Status .InstallPlanRef ).ToNot (Equal (nil ))
435
435
Expect (catalogCSV .GetName ()).To (Equal (subscription .Status .CurrentCSV ))
436
436
437
- // Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version (v1alpha1)
437
+ By ( " Check the error on the installplan - should be related to data loss and the CRD upgrade missing a stored version (v1alpha1)" )
438
438
Eventually (
439
439
func () (* operatorsv1alpha1.InstallPlan , error ) {
440
440
return crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Get (context .TODO (), subscription .Status .InstallPlanRef .Name , metav1.GetOptions {})
@@ -445,26 +445,26 @@ var _ = Describe("CRD Versions", func() {
445
445
Equal (operatorsv1alpha1 .InstallPlanPhaseFailed ),
446
446
))
447
447
448
- // update CRD status to remove the v1alpha1 stored version
448
+ By ( " update CRD status to remove the v1alpha1 stored version" )
449
449
newCRD , err := c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
450
450
Expect (err ).ToNot (HaveOccurred (), "error getting new CRD" )
451
451
newCRD .Status .StoredVersions = []string {"v1alpha2" }
452
452
newCRD , err = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().UpdateStatus (context .TODO (), newCRD , metav1.UpdateOptions {})
453
453
Expect (err ).ToNot (HaveOccurred (), "error updating new CRD" )
454
454
GinkgoT ().Logf ("new crd status stored versions: %#v" , newCRD .Status .StoredVersions ) // only v1alpha2 should be in the status now
455
455
456
- // install should now succeed
456
+ By ( " install should now succeed" )
457
457
oldInstallPlanRef := subscription .Status .InstallPlanRef .Name
458
458
err = crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Delete (context .TODO (), subscription .Status .InstallPlanRef .Name , metav1.DeleteOptions {})
459
459
Expect (err ).ToNot (HaveOccurred (), "error deleting failed install plan" )
460
- // remove old subscription
460
+ By ( " remove old subscription" )
461
461
err = crc .OperatorsV1alpha1 ().Subscriptions (generatedNamespace .GetName ()).Delete (context .TODO (), subscription .GetName (), metav1.DeleteOptions {})
462
462
Expect (err ).ToNot (HaveOccurred (), "error deleting old subscription" )
463
- // remove old csv
463
+ By ( " remove old csv" )
464
464
crc .OperatorsV1alpha1 ().ClusterServiceVersions (generatedNamespace .GetName ()).Delete (context .TODO (), mainPackageStable , metav1.DeleteOptions {})
465
465
Expect (err ).ToNot (HaveOccurred (), "error deleting old subscription" )
466
466
467
- // recreate subscription
467
+ By ( " recreate subscription" )
468
468
subscriptionNameNew := genName ("sub-nginx-update2-new-" )
469
469
_ = createSubscriptionForCatalog (crc , generatedNamespace .GetName (), subscriptionNameNew , mainCatalogName , mainPackageName , stableChannel , "" , operatorsv1alpha1 .ApprovalAutomatic )
470
470
@@ -474,14 +474,14 @@ var _ = Describe("CRD Versions", func() {
474
474
Expect (subscription .Status .InstallPlanRef ).ToNot (Equal (nil ))
475
475
Expect (catalogCSV .GetName ()).To (Equal (subscription .Status .CurrentCSV ))
476
476
477
- // eventually the subscription should create a new install plan
477
+ By ( " eventually the subscription should create a new install plan" )
478
478
Eventually (func () bool {
479
479
sub , _ := crc .OperatorsV1alpha1 ().Subscriptions (generatedNamespace .GetName ()).Get (context .TODO (), subscription .GetName (), metav1.GetOptions {})
480
480
GinkgoT ().Logf ("waiting for subscription %s to generate a new install plan..." , subscription .GetName ())
481
481
return sub .Status .InstallPlanRef .Name != oldInstallPlanRef
482
482
}, 5 * time .Minute , 10 * time .Second ).Should (BeTrue ())
483
483
484
- // eventually the new installplan should succeed
484
+ By ( " eventually the new installplan should succeed" )
485
485
Eventually (func () bool {
486
486
sub , _ := crc .OperatorsV1alpha1 ().Subscriptions (generatedNamespace .GetName ()).Get (context .TODO (), subscription .GetName (), metav1.GetOptions {})
487
487
ip , err := crc .OperatorsV1alpha1 ().InstallPlans (generatedNamespace .GetName ()).Get (context .TODO (), sub .Status .InstallPlanRef .Name , metav1.GetOptions {})
0 commit comments