Skip to content

Commit 10ad6b5

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 922f6ad commit 10ad6b5

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
@@ -936,8 +936,6 @@ var _ = Describe("Install Plan", func() {
936936
mainPackageDelta := fmt.Sprintf("%s-delta", mainPackageName)
937937

938938
stableChannel := "stable"
939-
betaChannel := "beta"
940-
deltaChannel := "delta"
941939

942940
// Create manifests
943941
mainManifests := []registry.PackageManifest{
@@ -1000,30 +998,17 @@ var _ = Describe("Install Plan", func() {
1000998
{
1001999
PackageName: mainPackageName,
10021000
Channels: []registry.PackageChannel{
1003-
{Name: stableChannel, CurrentCSVName: mainPackageStable},
1004-
{Name: betaChannel, CurrentCSVName: mainPackageBeta},
1001+
{Name: stableChannel, CurrentCSVName: mainPackageBeta},
10051002
},
1006-
DefaultChannelName: betaChannel,
1003+
DefaultChannelName: stableChannel,
10071004
},
10081005
}
10091006

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

@@ -1049,35 +1034,21 @@ var _ = Describe("Install Plan", func() {
10491034
validateCRDVersions(GinkgoT(), c, tt.oldCRD.GetName(), expectedVersions)
10501035

10511036
// Update the manifest
1052-
mainBetaCSV = newCSV(mainPackageBeta, testNamespace, "", semver.MustParse("0.2.0"), []apiextensions.CustomResourceDefinition{*tt.intermediateCRD}, nil, mainNamedStrategy)
10531037
mainManifests = []registry.PackageManifest{
10541038
{
10551039
PackageName: mainPackageName,
10561040
Channels: []registry.PackageChannel{
1057-
{Name: betaChannel, CurrentCSVName: mainPackageBeta},
1058-
{Name: deltaChannel, CurrentCSVName: mainPackageDelta},
1041+
{Name: stableChannel, CurrentCSVName: mainPackageDelta},
10591042
},
1060-
DefaultChannelName: deltaChannel,
1043+
DefaultChannelName: stableChannel,
10611044
},
10621045
}
10631046

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

0 commit comments

Comments
 (0)