@@ -14,95 +14,13 @@ import (
14
14
15
15
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
16
16
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
17
- apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
18
17
k8serrors "k8s.io/apimachinery/pkg/api/errors"
19
18
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20
19
)
21
20
22
21
var _ = Describe ("CRD Versions" , func () {
23
22
AfterEach (func () { TearDown (testNamespace ) }, float64 (30 ))
24
23
25
- It ("creates v1beta1 crds with a v1beta1 schema successfully" , func () {
26
- By ("This test proves that OLM is able to handle v1beta1 CRDs successfully. Creating v1 CRDs has more " +
27
- "restrictions around the schema. v1beta1 validation schemas are not necessarily valid in v1. " +
28
- "OLM should support both v1beta1 and v1 CRDs" )
29
- c := newKubeClient ()
30
- crc := newCRClient ()
31
-
32
- mainPackageName := genName ("nginx-update2-" )
33
- mainPackageStable := fmt .Sprintf ("%s-stable" , mainPackageName )
34
- stableChannel := "stable"
35
-
36
- crdPlural := genName ("ins-v1beta1-" )
37
- crdName := crdPlural + ".cluster.com"
38
- mainCRD := apiextensions.CustomResourceDefinition {
39
- ObjectMeta : metav1.ObjectMeta {
40
- Name : crdName ,
41
- },
42
- Spec : apiextensions.CustomResourceDefinitionSpec {
43
- Group : "cluster.com" ,
44
- Versions : []apiextensions.CustomResourceDefinitionVersion {
45
- {
46
- Name : "v1alpha1" ,
47
- Served : true ,
48
- Storage : true ,
49
- },
50
- },
51
- Names : apiextensions.CustomResourceDefinitionNames {
52
- Plural : crdPlural ,
53
- Singular : crdPlural ,
54
- Kind : crdPlural ,
55
- ListKind : "list" + crdPlural ,
56
- },
57
- Scope : "Namespaced" ,
58
- // this validation is not a valid v1 structural schema because the "type: object" field is missing
59
- Validation : & apiextensions.CustomResourceValidation {
60
- OpenAPIV3Schema : & apiextensions.JSONSchemaProps {
61
- Description : "my crd schema" ,
62
- },
63
- },
64
- },
65
- }
66
-
67
- mainCSV := newCSV (mainPackageStable , testNamespace , "" , semver .MustParse ("0.1.0" ), []apiextensions.CustomResourceDefinition {mainCRD }, nil , nil )
68
- mainCatalogName := genName ("mock-ocs-main-update2-" )
69
- mainManifests := []registry.PackageManifest {
70
- {
71
- PackageName : mainPackageName ,
72
- Channels : []registry.PackageChannel {
73
- {Name : stableChannel , CurrentCSVName : mainPackageStable },
74
- },
75
- DefaultChannelName : stableChannel ,
76
- },
77
- }
78
-
79
- // Create the catalog sources
80
- _ , cleanupMainCatalogSource := createInternalCatalogSource (c , crc , mainCatalogName , testNamespace , mainManifests , []apiextensions.CustomResourceDefinition {mainCRD }, []operatorsv1alpha1.ClusterServiceVersion {mainCSV })
81
- defer cleanupMainCatalogSource ()
82
-
83
- // Attempt to get the catalog source before creating install plan
84
- _ , err := fetchCatalogSourceOnStatus (crc , mainCatalogName , testNamespace , catalogSourceRegistryPodSynced )
85
- Expect (err ).ToNot (HaveOccurred ())
86
-
87
- subscriptionName := genName ("sub-nginx-update2-" )
88
- subscriptionCleanup := createSubscriptionForCatalog (crc , testNamespace , subscriptionName , mainCatalogName , mainPackageName , stableChannel , "" , operatorsv1alpha1 .ApprovalAutomatic )
89
- defer subscriptionCleanup ()
90
-
91
- subscription , err := fetchSubscription (crc , testNamespace , subscriptionName , subscriptionHasInstallPlanChecker )
92
- Expect (err ).ToNot (HaveOccurred ())
93
- Expect (subscription ).ToNot (Equal (nil ))
94
- Expect (subscription .Status .InstallPlanRef ).ToNot (Equal (nil ))
95
- Expect (mainCSV .GetName ()).To (Equal (subscription .Status .CurrentCSV ))
96
-
97
- installPlanName := subscription .Status .InstallPlanRef .Name
98
-
99
- // Wait for InstallPlan to be status: Complete before checking resource presence
100
- fetchedInstallPlan , err := fetchInstallPlan (GinkgoT (), crc , installPlanName , buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseComplete ))
101
- Expect (err ).ToNot (HaveOccurred ())
102
- GinkgoT ().Logf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase )
103
- Expect (fetchedInstallPlan .Status .Phase ).To (Equal (operatorsv1alpha1 .InstallPlanPhaseComplete ))
104
- })
105
-
106
24
It ("creates v1 CRDs with a v1 schema successfully" , func () {
107
25
By ("v1 crds with a valid openapiv3 schema should be created successfully by OLM" )
108
26
c := newKubeClient ()
@@ -112,7 +30,7 @@ var _ = Describe("CRD Versions", func() {
112
30
mainPackageStable := fmt .Sprintf ("%s-stable" , mainPackageName )
113
31
stableChannel := "stable"
114
32
115
- crdPlural := genName ("ins-v1beta1- " )
33
+ crdPlural := genName ("ins-" )
116
34
crdName := crdPlural + ".cluster.com"
117
35
v1crd := apiextensionsv1.CustomResourceDefinition {
118
36
ObjectMeta : metav1.ObjectMeta {
@@ -185,7 +103,7 @@ var _ = Describe("CRD Versions", func() {
185
103
mainPackageStable := fmt .Sprintf ("%s-stable" , mainPackageName )
186
104
stableChannel := "stable"
187
105
188
- crdPlural := genName ("ins-v1beta1- " )
106
+ crdPlural := genName ("ins-" )
189
107
crdName := crdPlural + ".cluster.com"
190
108
oldCRD := apiextensions.CustomResourceDefinition {
191
109
ObjectMeta : metav1.ObjectMeta {
@@ -352,20 +270,20 @@ var _ = Describe("CRD Versions", func() {
352
270
crdName := crdPlural + ".cluster.com"
353
271
crdGroup := "cluster.com"
354
272
355
- oldCRD := & apiextensionsv1beta1 .CustomResourceDefinition {
273
+ oldCRD := & apiextensionsv1 .CustomResourceDefinition {
356
274
ObjectMeta : metav1.ObjectMeta {
357
275
Name : crdName ,
358
276
},
359
- Spec : apiextensionsv1beta1 .CustomResourceDefinitionSpec {
277
+ Spec : apiextensionsv1 .CustomResourceDefinitionSpec {
360
278
Group : crdGroup ,
361
- Versions : []apiextensionsv1beta1 .CustomResourceDefinitionVersion {
279
+ Versions : []apiextensionsv1 .CustomResourceDefinitionVersion {
362
280
{
363
281
Name : "v1alpha1" ,
364
282
Served : true ,
365
283
Storage : true ,
366
284
},
367
285
},
368
- Names : apiextensionsv1beta1 .CustomResourceDefinitionNames {
286
+ Names : apiextensionsv1 .CustomResourceDefinitionNames {
369
287
Plural : crdPlural ,
370
288
Singular : crdPlural ,
371
289
Kind : crdPlural ,
@@ -374,12 +292,12 @@ var _ = Describe("CRD Versions", func() {
374
292
Scope : "Namespaced" ,
375
293
},
376
294
}
377
- _ , err := c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Create (context .TODO (), oldCRD , metav1.CreateOptions {})
295
+ _ , err := c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Create (context .TODO (), oldCRD , metav1.CreateOptions {})
378
296
Expect (err ).ToNot (HaveOccurred (), "error creating old CRD" )
379
297
380
298
// wrap CRD update in a poll because of the object has been modified related errors
381
299
Eventually (func () error {
382
- oldCRD , err = c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
300
+ oldCRD , err = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
383
301
if err != nil {
384
302
return err
385
303
}
@@ -388,13 +306,13 @@ var _ = Describe("CRD Versions", func() {
388
306
// set v1alpha1 to no longer served
389
307
oldCRD .Spec .Versions [0 ].Storage = false
390
308
// update CRD on-cluster with a new version
391
- oldCRD .Spec .Versions = append (oldCRD .Spec .Versions , apiextensionsv1beta1 .CustomResourceDefinitionVersion {
309
+ oldCRD .Spec .Versions = append (oldCRD .Spec .Versions , apiextensionsv1 .CustomResourceDefinitionVersion {
392
310
Name : "v1alpha2" ,
393
311
Served : true ,
394
312
Storage : true ,
395
313
})
396
314
397
- updatedCRD , err := c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Update (context .TODO (), oldCRD , metav1.UpdateOptions {})
315
+ updatedCRD , err := c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Update (context .TODO (), oldCRD , metav1.UpdateOptions {})
398
316
if err != nil {
399
317
return err
400
318
}
@@ -471,10 +389,10 @@ var _ = Describe("CRD Versions", func() {
471
389
))
472
390
473
391
// update CRD status to remove the v1alpha1 stored version
474
- newCRD , err := c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
392
+ newCRD , err := c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Get (context .TODO (), oldCRD .GetName (), metav1.GetOptions {})
475
393
Expect (err ).ToNot (HaveOccurred (), "error getting new CRD" )
476
394
newCRD .Status .StoredVersions = []string {"v1alpha2" }
477
- newCRD , err = c .ApiextensionsInterface ().ApiextensionsV1beta1 ().CustomResourceDefinitions ().UpdateStatus (context .TODO (), newCRD , metav1.UpdateOptions {})
395
+ newCRD , err = c .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().UpdateStatus (context .TODO (), newCRD , metav1.UpdateOptions {})
478
396
Expect (err ).ToNot (HaveOccurred (), "error updating new CRD" )
479
397
GinkgoT ().Logf ("new crd status stored versions: %#v" , newCRD .Status .StoredVersions ) // only v1alpha2 should be in the status now
480
398
0 commit comments