Skip to content

Commit 7378578

Browse files
committed
Fix validate CRD compatibility check and deprecated CRD test case
1. Fix validate CRD compatibility Should only run against served versions instead the non-served versions (! operator error) 2. Clean up the deprecated CRD versions test: Using standup catsrc upgrade and get rid of unnecessary subscription deletion. Signed-off-by: Vu Dinh <[email protected]>
1 parent 171bd7e commit 7378578

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ func validateV1CRDCompatibility(dynamicClient dynamic.Interface, oldCRD *apiexte
13591359
return err
13601360
}
13611361
for _, version := range oldCRD.Spec.Versions {
1362-
if !version.Served {
1362+
if version.Served {
13631363
gvr := schema.GroupVersionResource{Group: oldCRD.Spec.Group, Version: version.Name, Resource: oldCRD.Spec.Names.Plural}
13641364
err := validateExistingCRs(dynamicClient, gvr, convertedCRD)
13651365
if err != nil {
@@ -1382,7 +1382,7 @@ func validateV1Beta1CRDCompatibility(dynamicClient dynamic.Interface, oldCRD *ap
13821382
return err
13831383
}
13841384
for _, version := range oldCRD.Spec.Versions {
1385-
if !version.Served {
1385+
if version.Served {
13861386
gvr := schema.GroupVersionResource{Group: oldCRD.Spec.Group, Version: version.Name, Resource: oldCRD.Spec.Names.Plural}
13871387
err := validateExistingCRs(dynamicClient, gvr, convertedCRD)
13881388
if err != nil {

test/e2e/installplan_e2e_test.go

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,6 @@ var _ = Describe("Install Plan", func() {
934934
mainPackageDelta := fmt.Sprintf("%s-delta", mainPackageName)
935935

936936
stableChannel := "stable"
937-
betaChannel := "beta"
938-
deltaChannel := "delta"
939937

940938
// Create manifests
941939
mainManifests := []registry.PackageManifest{
@@ -998,30 +996,17 @@ var _ = Describe("Install Plan", func() {
998996
{
999997
PackageName: mainPackageName,
1000998
Channels: []registry.PackageChannel{
1001-
{Name: stableChannel, CurrentCSVName: mainPackageStable},
1002-
{Name: betaChannel, CurrentCSVName: mainPackageBeta},
999+
{Name: stableChannel, CurrentCSVName: mainPackageBeta},
10031000
},
1004-
DefaultChannelName: betaChannel,
1001+
DefaultChannelName: stableChannel,
10051002
},
10061003
}
10071004

10081005
updateInternalCatalog(GinkgoT(), c, crc, mainCatalogSourceName, testNamespace, []apiextensions.CustomResourceDefinition{*tt.intermediateCRD}, []operatorsv1alpha1.ClusterServiceVersion{mainStableCSV, mainBetaCSV}, mainManifests)
1009-
10101006
// Attempt to get the catalog source before creating install plan(s)
10111007
_, err = fetchCatalogSourceOnStatus(crc, mainCatalogSourceName, testNamespace, catalogSourceRegistryPodSynced)
10121008
require.NoError(GinkgoT(), err)
1013-
1014-
// Update the subscription resource to point to the beta CSV
1015-
err = crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.TODO(), *metav1.NewDeleteOptions(0), metav1.ListOptions{})
1016-
require.NoError(GinkgoT(), err)
1017-
1018-
// Delete orphaned csv
1019-
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().ClusterServiceVersions(testNamespace).Delete(context.TODO(), mainStableCSV.GetName(), metav1.DeleteOptions{}))
1020-
1021-
// existing cleanup should remove this
1022-
createSubscriptionForCatalog(crc, testNamespace, subscriptionName, mainCatalogSourceName, mainPackageName, betaChannel, "", operatorsv1alpha1.ApprovalAutomatic)
1023-
1024-
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
1009+
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanDifferentChecker(installPlanName))
10251010
require.NoError(GinkgoT(), err)
10261011
require.NotNil(GinkgoT(), subscription)
10271012

@@ -1047,35 +1032,21 @@ var _ = Describe("Install Plan", func() {
10471032
validateCRDVersions(GinkgoT(), c, tt.oldCRD.GetName(), expectedVersions)
10481033

10491034
// Update the manifest
1050-
mainBetaCSV = newCSV(mainPackageBeta, testNamespace, "", semver.MustParse("0.2.0"), []apiextensions.CustomResourceDefinition{*tt.intermediateCRD}, nil, mainNamedStrategy)
10511035
mainManifests = []registry.PackageManifest{
10521036
{
10531037
PackageName: mainPackageName,
10541038
Channels: []registry.PackageChannel{
1055-
{Name: betaChannel, CurrentCSVName: mainPackageBeta},
1056-
{Name: deltaChannel, CurrentCSVName: mainPackageDelta},
1039+
{Name: stableChannel, CurrentCSVName: mainPackageDelta},
10571040
},
1058-
DefaultChannelName: deltaChannel,
1041+
DefaultChannelName: stableChannel,
10591042
},
10601043
}
10611044

1062-
updateInternalCatalog(GinkgoT(), c, crc, mainCatalogSourceName, testNamespace, []apiextensions.CustomResourceDefinition{*tt.newCRD}, []operatorsv1alpha1.ClusterServiceVersion{mainBetaCSV, mainDeltaCSV}, mainManifests)
1063-
1045+
updateInternalCatalog(GinkgoT(), c, crc, mainCatalogSourceName, testNamespace, []apiextensions.CustomResourceDefinition{*tt.newCRD}, []operatorsv1alpha1.ClusterServiceVersion{mainStableCSV, mainBetaCSV, mainDeltaCSV}, mainManifests)
10641046
// Attempt to get the catalog source before creating install plan(s)
10651047
_, err = fetchCatalogSourceOnStatus(crc, mainCatalogSourceName, testNamespace, catalogSourceRegistryPodSynced)
10661048
require.NoError(GinkgoT(), err)
1067-
1068-
// Update the subscription resource to point to the beta CSV
1069-
err = crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.TODO(), *metav1.NewDeleteOptions(0), metav1.ListOptions{})
1070-
require.NoError(GinkgoT(), err)
1071-
1072-
// Delete orphaned csv
1073-
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().ClusterServiceVersions(testNamespace).Delete(context.TODO(), mainBetaCSV.GetName(), metav1.DeleteOptions{}))
1074-
1075-
// existing cleanup should remove this
1076-
createSubscriptionForCatalog(crc, testNamespace, subscriptionName, mainCatalogSourceName, mainPackageName, deltaChannel, "", operatorsv1alpha1.ApprovalAutomatic)
1077-
1078-
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
1049+
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanDifferentChecker(installPlanName))
10791050
require.NoError(GinkgoT(), err)
10801051
require.NotNil(GinkgoT(), subscription)
10811052

0 commit comments

Comments
 (0)