From 9748c0372b9a27f13c751970300775625813df49 Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Thu, 2 May 2024 17:28:20 -0400 Subject: [PATCH] remove olm.bundle.mediatype property and clusterextension support for plain+v0 Signed-off-by: Joe Lanford --- Makefile | 3 - internal/catalogmetadata/types.go | 28 ---- internal/catalogmetadata/types_test.go | 56 ------- .../clusterextension_controller.go | 34 +--- .../clusterextension_controller_test.go | 150 ------------------ internal/controllers/extension_controller.go | 26 +-- test/e2e/cluster_extension_install_test.go | 57 ------- .../extension_developer_test.go | 9 -- test/extension-developer-e2e/setup.sh | 87 +--------- .../bundles/plain-v0/plain.v0.1.0/Dockerfile | 2 - .../plain.v0.1.0/manifests/configmap.yaml | 19 --- testdata/catalogs/test-catalog/catalog.yaml | 24 +-- 12 files changed, 11 insertions(+), 484 deletions(-) delete mode 100644 testdata/bundles/plain-v0/plain.v0.1.0/Dockerfile delete mode 100644 testdata/bundles/plain-v0/plain.v0.1.0/manifests/configmap.yaml diff --git a/Makefile b/Makefile index 7b539c244..75416bd18 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,6 @@ e2e: $(SETUP_ENVTEST) #EXHELP Run the e2e tests. E2E_REGISTRY_NAME := docker-registry E2E_REGISTRY_NAMESPACE := operator-controller-e2e export REG_PKG_NAME := registry-operator -export PLAIN_PKG_NAME := plain-operator export CATALOG_IMG := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000/test-catalog:e2e .PHONY: test-ext-dev-e2e test-ext-dev-e2e: $(SETUP_ENVTEST) $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension create, upgrade and delete tests. @@ -187,12 +186,10 @@ kind-load-test-artifacts: $(KIND) #EXHELP Load the e2e testdata container images $(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1 $(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0 $(CONTAINER_RUNTIME) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0 - $(CONTAINER_RUNTIME) build testdata/bundles/plain-v0/plain.v0.1.0 -t localhost/testdata/bundles/plain-v0/plain:v0.1.0 $(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 --name $(KIND_CLUSTER_NAME) $(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1 --name $(KIND_CLUSTER_NAME) $(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0 --name $(KIND_CLUSTER_NAME) $(KIND) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0 --name $(KIND_CLUSTER_NAME) - $(KIND) load docker-image localhost/testdata/bundles/plain-v0/plain:v0.1.0 --name $(KIND_CLUSTER_NAME) #SECTION Build diff --git a/internal/catalogmetadata/types.go b/internal/catalogmetadata/types.go index e1cb8e2e8..b1d326ee6 100644 --- a/internal/catalogmetadata/types.go +++ b/internal/catalogmetadata/types.go @@ -11,12 +11,6 @@ import ( "github.com/operator-framework/operator-registry/alpha/property" ) -const ( - MediaTypePlain = "plain+v0" - MediaTypeRegistry = "registry+v1" - PropertyBundleMediaType = "olm.bundle.mediatype" -) - type Schemas interface { Package | Bundle | Channel | Deprecation } @@ -50,7 +44,6 @@ type Bundle struct { bundlePackage *property.Package semVersion *bsemver.Version requiredPackages []PackageRequired - mediaType *string } func (b *Bundle) Version() (*bsemver.Version, error) { @@ -67,14 +60,6 @@ func (b *Bundle) RequiredPackages() ([]PackageRequired, error) { return b.requiredPackages, nil } -func (b *Bundle) MediaType() (string, error) { - if err := b.loadMediaType(); err != nil { - return "", err - } - - return *b.mediaType, nil -} - func (b *Bundle) loadPackage() error { b.mu.Lock() defer b.mu.Unlock() @@ -120,19 +105,6 @@ func (b *Bundle) loadRequiredPackages() error { return nil } -func (b *Bundle) loadMediaType() error { - b.mu.Lock() - defer b.mu.Unlock() - if b.mediaType == nil { - mediaType, err := loadOneFromProps[string](b, PropertyBundleMediaType, false) - if err != nil { - return fmt.Errorf("error determining bundle mediatype for bundle %q: %s", b.Name, err) - } - b.mediaType = &mediaType - } - return nil -} - func (b *Bundle) propertiesByType(propType string) []*property.Property { if b.propertiesMap == nil { b.propertiesMap = make(map[string][]*property.Property) diff --git a/internal/catalogmetadata/types_test.go b/internal/catalogmetadata/types_test.go index 3129ecde3..743555de2 100644 --- a/internal/catalogmetadata/types_test.go +++ b/internal/catalogmetadata/types_test.go @@ -2,7 +2,6 @@ package catalogmetadata_test import ( "encoding/json" - "fmt" "testing" bsemver "github.com/blang/semver/v4" @@ -147,61 +146,6 @@ func TestBundleRequiredPackages(t *testing.T) { } } -func TestBundleMediaType(t *testing.T) { - for _, tt := range []struct { - name string - bundle *catalogmetadata.Bundle - wantMediaType string - wantErr string - }{ - { - name: "valid mediatype property", - bundle: &catalogmetadata.Bundle{Bundle: declcfg.Bundle{ - Name: "fake-bundle.v1", - Properties: []property.Property{ - { - Type: catalogmetadata.PropertyBundleMediaType, - Value: json.RawMessage(fmt.Sprintf(`"%s"`, catalogmetadata.MediaTypePlain)), - }, - }, - }}, - wantMediaType: catalogmetadata.MediaTypePlain, - }, - { - name: "no media type provided", - bundle: &catalogmetadata.Bundle{Bundle: declcfg.Bundle{ - Name: "fake-bundle.noMediaType", - Properties: []property.Property{}, - }}, - wantMediaType: "", - }, - { - name: "malformed media type", - bundle: &catalogmetadata.Bundle{Bundle: declcfg.Bundle{ - Name: "fake-bundle.badMediaType", - Properties: []property.Property{ - { - Type: catalogmetadata.PropertyBundleMediaType, - Value: json.RawMessage("badtype"), - }, - }, - }}, - wantMediaType: "", - wantErr: `error determining bundle mediatype for bundle "fake-bundle.badMediaType": property "olm.bundle.mediatype" with value "badtype" could not be parsed: invalid character 'b' looking for beginning of value`, - }, - } { - t.Run(tt.name, func(t *testing.T) { - mediaType, err := tt.bundle.MediaType() - assert.Equal(t, tt.wantMediaType, mediaType) - if tt.wantErr != "" { - assert.EqualError(t, err, tt.wantErr) - } else { - assert.NoError(t, err) - } - }) - } -} - func TestBundleHasDeprecation(t *testing.T) { for _, tt := range []struct { name string diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 56575fbad..75109a228 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -135,25 +135,16 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp // TODO: Question - Should we set the deprecation statuses after we have successfully resolved instead of after a successful installation? - mediaType, err := bundle.MediaType() - if err != nil { - setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) - setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) - return ctrl.Result{}, err - } - if err := r.validateBundle(bundle); err != nil { setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) return ctrl.Result{}, err } - bundleProvisioner, err := mapBundleMediaTypeToBundleProvisioner(mediaType) - if err != nil { - setInstalledStatusConditionFailed(&ext.Status.Conditions, err.Error(), ext.GetGeneration()) - setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) - return ctrl.Result{}, err - } + // Assume all bundles are registry+v1 for now, since that's all we support. + // If the bundle is not a registry+v1 bundle, the conversion will fail. + bundleProvisioner := "core-rukpak-io-registry" + // Ensure a BundleDeployment exists with its bundle source from the bundle // image we just looked up in the solution. dep := r.GenerateExpectedBundleDeployment(*ext, bundle.Image, bundleProvisioner) @@ -523,23 +514,6 @@ func (r *ClusterExtensionReconciler) existingBundleDeploymentUnstructured(ctx co return &unstructured.Unstructured{Object: unstrExistingBundleDeploymentObj}, nil } -// mapBundleMediaTypeToBundleProvisioner maps an olm.bundle.mediatype property to a -// rukpak bundle provisioner class name that is capable of unpacking the bundle type -func mapBundleMediaTypeToBundleProvisioner(mediaType string) (string, error) { - switch mediaType { - case catalogmetadata.MediaTypePlain: - return "core-rukpak-io-plain", nil - // To ensure compatibility with bundles created with OLMv0 where the - // olm.bundle.mediatype property doesn't exist, we assume that if the - // property is empty (i.e doesn't exist) that the bundle is one created - // with OLMv0 and therefore should use the registry provisioner - case catalogmetadata.MediaTypeRegistry, "": - return "core-rukpak-io-registry", nil - default: - return "", fmt.Errorf("unknown bundle mediatype: %s", mediaType) - } -} - // Generate reconcile requests for all cluster extensions affected by a catalog change func clusterExtensionRequestsForCatalog(c client.Reader, logger logr.Logger) handler.MapFunc { return func(ctx context.Context, _ client.Object) []reconcile.Request { diff --git a/internal/controllers/clusterextension_controller_test.go b/internal/controllers/clusterextension_controller_test.go index 418bd4a0e..f5f389514 100644 --- a/internal/controllers/clusterextension_controller_test.go +++ b/internal/controllers/clusterextension_controller_test.go @@ -909,116 +909,6 @@ func TestClusterExtensionNoVersion(t *testing.T) { require.NoError(t, cl.DeleteAllOf(ctx, &rukpakv1alpha2.BundleDeployment{})) } -func TestClusterExtensionPlainV0Bundle(t *testing.T) { - cl, reconciler := newClientAndReconciler(t) - ctx := context.Background() - extKey := types.NamespacedName{Name: fmt.Sprintf("cluster-extension-test-%s", rand.String(8))} - - t.Log("When the cluster extension specifies a package with a plain+v0 bundle") - t.Log("By initializing cluster state") - pkgName := "plain" - pkgVer := "0.1.0" - pkgChan := "beta" - clusterExtension := &ocv1alpha1.ClusterExtension{ - ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - PackageName: pkgName, - Version: pkgVer, - Channel: pkgChan, - InstallNamespace: "default", - }, - } - require.NoError(t, cl.Create(ctx, clusterExtension)) - - t.Log("It sets resolution success status") - t.Log("By running reconcile") - res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey}) - require.Equal(t, ctrl.Result{}, res) - require.NoError(t, err) - - t.Log("By fetching updated cluster extension after reconcile") - require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) - - t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/plain/0.1.0", Version: "0.1.0"}, clusterExtension.Status.ResolvedBundle) - require.Empty(t, clusterExtension.Status.InstalledBundle) - t.Log("By checking the expected conditions") - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) - require.NotNil(t, cond) - require.Equal(t, metav1.ConditionTrue, cond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, cond.Reason) - require.Equal(t, "resolved to \"quay.io/operatorhub/plain@sha256:plain\"", cond.Message) - cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) - require.NotNil(t, cond) - require.Equal(t, metav1.ConditionUnknown, cond.Status) - require.Equal(t, ocv1alpha1.ReasonInstallationStatusUnknown, cond.Reason) - require.Equal(t, "bundledeployment status is unknown", cond.Message) - - t.Log("By fetching the bundled deployment") - bd := &rukpakv1alpha2.BundleDeployment{} - require.NoError(t, cl.Get(ctx, types.NamespacedName{Name: extKey.Name}, bd)) - require.Equal(t, "core-rukpak-io-plain", bd.Spec.ProvisionerClassName) - require.Equal(t, rukpakv1alpha2.SourceTypeImage, bd.Spec.Source.Type) - require.NotNil(t, bd.Spec.Source.Image) - require.Equal(t, "quay.io/operatorhub/plain@sha256:plain", bd.Spec.Source.Image.Ref) - - verifyInvariants(ctx, t, reconciler.Client, clusterExtension) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) - require.NoError(t, cl.DeleteAllOf(ctx, &rukpakv1alpha2.BundleDeployment{})) -} - -func TestClusterExtensionBadBundleMediaType(t *testing.T) { - cl, reconciler := newClientAndReconciler(t) - ctx := context.Background() - extKey := types.NamespacedName{Name: fmt.Sprintf("cluster-extension-test-%s", rand.String(8))} - - t.Log("When the cluster extension specifies a package with a bad bundle mediatype") - t.Log("By initializing cluster state") - pkgName := "badmedia" - pkgVer := "0.1.0" - pkgChan := "beta" - clusterExtension := &ocv1alpha1.ClusterExtension{ - ObjectMeta: metav1.ObjectMeta{Name: extKey.Name}, - Spec: ocv1alpha1.ClusterExtensionSpec{ - PackageName: pkgName, - Version: pkgVer, - Channel: pkgChan, - InstallNamespace: "default", - }, - } - require.NoError(t, cl.Create(ctx, clusterExtension)) - - t.Log("It sets resolution success status") - t.Log("By running reconcile") - res, err := reconciler.Reconcile(ctx, ctrl.Request{NamespacedName: extKey}) - require.Equal(t, ctrl.Result{}, res) - require.Error(t, err) - require.ErrorContains(t, err, "unknown bundle mediatype: badmedia+v1") - - t.Log("By fetching updated cluster extension after reconcile") - require.NoError(t, cl.Get(ctx, extKey, clusterExtension)) - - t.Log("By checking the status fields") - require.Equal(t, &ocv1alpha1.BundleMetadata{Name: "operatorhub/badmedia/0.1.0", Version: "0.1.0"}, clusterExtension.Status.ResolvedBundle) - require.Empty(t, clusterExtension.Status.InstalledBundle) - - t.Log("By checking the expected conditions") - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) - require.NotNil(t, cond) - require.Equal(t, metav1.ConditionTrue, cond.Status) - require.Equal(t, ocv1alpha1.ReasonSuccess, cond.Reason) - require.Equal(t, "resolved to \"quay.io/operatorhub/badmedia@sha256:badmedia\"", cond.Message) - cond = apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) - require.NotNil(t, cond) - require.Equal(t, metav1.ConditionFalse, cond.Status) - require.Equal(t, ocv1alpha1.ReasonInstallationFailed, cond.Reason) - require.Equal(t, "unknown bundle mediatype: badmedia+v1", cond.Message) - - verifyInvariants(ctx, t, reconciler.Client, clusterExtension) - require.NoError(t, cl.DeleteAllOf(ctx, &ocv1alpha1.ClusterExtension{})) - require.NoError(t, cl.DeleteAllOf(ctx, &rukpakv1alpha2.BundleDeployment{})) -} - func verifyInvariants(ctx context.Context, t *testing.T, c client.Client, ext *ocv1alpha1.ClusterExtension) { key := client.ObjectKeyFromObject(ext) require.NoError(t, c.Get(ctx, key, ext)) @@ -2000,18 +1890,6 @@ var ( }, }, } - plainBetaChannel = catalogmetadata.Channel{ - Channel: declcfg.Channel{ - Name: "beta", - Package: "plain", - }, - } - badmediaBetaChannel = catalogmetadata.Channel{ - Channel: declcfg.Channel{ - Name: "beta", - Package: "badmedia", - }, - } ) var testBundleList = []*catalogmetadata.Bundle{ @@ -2080,32 +1958,4 @@ var testBundleList = []*catalogmetadata.Bundle{ CatalogName: "fake-catalog", InChannels: []*catalogmetadata.Channel{&prometheusBetaChannel}, }, - { - Bundle: declcfg.Bundle{ - Name: "operatorhub/plain/0.1.0", - Package: "plain", - Image: "quay.io/operatorhub/plain@sha256:plain", - Properties: []property.Property{ - {Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"plain","version":"0.1.0"}`)}, - {Type: property.TypeGVK, Value: json.RawMessage(`[]`)}, - {Type: "olm.bundle.mediatype", Value: json.RawMessage(`"plain+v0"`)}, - }, - }, - CatalogName: "fake-catalog", - InChannels: []*catalogmetadata.Channel{&plainBetaChannel}, - }, - { - Bundle: declcfg.Bundle{ - Name: "operatorhub/badmedia/0.1.0", - Package: "badmedia", - Image: "quay.io/operatorhub/badmedia@sha256:badmedia", - Properties: []property.Property{ - {Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"badmedia","version":"0.1.0"}`)}, - {Type: property.TypeGVK, Value: json.RawMessage(`[]`)}, - {Type: "olm.bundle.mediatype", Value: json.RawMessage(`"badmedia+v1"`)}, - }, - }, - CatalogName: "fake-catalog", - InChannels: []*catalogmetadata.Channel{&badmediaBetaChannel}, - }, } diff --git a/internal/controllers/extension_controller.go b/internal/controllers/extension_controller.go index 5c69eb5cf..82fb22422 100644 --- a/internal/controllers/extension_controller.go +++ b/internal/controllers/extension_controller.go @@ -164,31 +164,7 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext ext.Status.ResolvedBundle = bundleMetadataFor(bundle) setResolvedStatusConditionSuccess(&ext.Status.Conditions, fmt.Sprintf("resolved to %q", bundle.Image), ext.GetGeneration()) - mediaType, err := bundle.MediaType() - if err != nil { - if c := apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeInstalled); c == nil { - ext.Status.InstalledBundle = nil - setInstalledStatusConditionFailed(&ext.Status.Conditions, fmt.Sprintf("failed to read bundle mediaType: %v", err), ext.GetGeneration()) - setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) - } - setProgressingStatusConditionFailed(&ext.Status.Conditions, fmt.Sprintf("failed to read bundle mediaType: %v", err), ext.GetGeneration()) - return ctrl.Result{}, err - } - - // TODO: this needs to include the registryV1 bundle option. As of this PR, this only supports direct - // installation of a set of manifests. - if mediaType != catalogmetadata.MediaTypePlain { - if c := apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeInstalled); c == nil { - // Set the TypeInstalled condition to Failed to indicate that the resolution - // hasn't been attempted yet, due to the spec being invalid. - ext.Status.InstalledBundle = nil - setInstalledStatusConditionFailed(&ext.Status.Conditions, fmt.Sprintf("bundle type %s not supported currently", mediaType), ext.GetGeneration()) - setDeprecationStatusesUnknown(&ext.Status.Conditions, "deprecation checks have not been attempted as installation has failed", ext.GetGeneration()) - } - setProgressingStatusConditionFailed(&ext.Status.Conditions, fmt.Sprintf("bundle type %s not supported currently", mediaType), ext.GetGeneration()) - return ctrl.Result{}, nil - } - + // Right now, we just assume that the bundle is a plain+v0 bundle. app, err := r.GenerateExpectedApp(*ext, bundle) if err != nil { if c := apimeta.FindStatusCondition(ext.Status.Conditions, ocv1alpha1.TypeInstalled); c == nil { diff --git a/test/e2e/cluster_extension_install_test.go b/test/e2e/cluster_extension_install_test.go index 3f2b7df86..d7fc3c300 100644 --- a/test/e2e/cluster_extension_install_test.go +++ b/test/e2e/cluster_extension_install_test.go @@ -121,63 +121,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) { }, pollDuration, pollInterval) } -func TestClusterExtensionInstallPlain(t *testing.T) { - t.Log("When a cluster extension is installed from a catalog") - t.Log("When the cluster extension bundle format is plain+v0") - - clusterExtension, clusterExtensionName, extensionCatalog := testInit(t) - defer testCleanup(t, extensionCatalog, clusterExtension) - defer getArtifactsOutput(t) - - clusterExtension.Spec = ocv1alpha1.ClusterExtensionSpec{ - PackageName: "plain", - InstallNamespace: "default", - } - t.Log("It resolves the specified package with correct bundle path") - t.Log("By creating the ClusterExtension resource") - require.NoError(t, c.Create(context.Background(), clusterExtension)) - - t.Log("By eventually reporting a successful resolution and bundle path") - require.EventuallyWithT(t, func(ct *assert.CollectT) { - assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - assert.Len(ct, clusterExtension.Status.Conditions, 6) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeResolved) - if !assert.NotNil(ct, cond) { - return - } - assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) - assert.Contains(ct, cond.Message, "resolved to") - assert.NotEmpty(ct, clusterExtension.Status.ResolvedBundle) - }, pollDuration, pollInterval) - - t.Log("By eventually installing the package successfully") - require.EventuallyWithT(t, func(ct *assert.CollectT) { - assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension)) - cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1alpha1.TypeInstalled) - if !assert.NotNil(ct, cond) { - return - } - assert.Equal(ct, metav1.ConditionTrue, cond.Status) - assert.Equal(ct, ocv1alpha1.ReasonSuccess, cond.Reason) - assert.Contains(ct, cond.Message, "installed from") - assert.NotEmpty(ct, clusterExtension.Status.InstalledBundle) - - bd := rukpakv1alpha2.BundleDeployment{} - assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtensionName}, &bd)) - isUnpackSuccessful := apimeta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeUnpacked) - if !assert.NotNil(ct, isUnpackSuccessful) { - return - } - assert.Equal(ct, rukpakv1alpha2.ReasonUnpackSuccessful, isUnpackSuccessful.Reason) - installed := apimeta.FindStatusCondition(bd.Status.Conditions, rukpakv1alpha2.TypeInstalled) - if !assert.NotNil(ct, installed) { - return - } - assert.Equal(ct, rukpakv1alpha2.ReasonInstallationSucceeded, installed.Reason) - }, pollDuration, pollInterval) -} - func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) { t.Log("When a cluster extension is installed from a catalog") t.Log("It resolves again when a new catalog is available") diff --git a/test/extension-developer-e2e/extension_developer_test.go b/test/extension-developer-e2e/extension_developer_test.go index cb7b5f7d0..4b4bbe219 100644 --- a/test/extension-developer-e2e/extension_developer_test.go +++ b/test/extension-developer-e2e/extension_developer_test.go @@ -32,15 +32,6 @@ func TestExtensionDeveloper(t *testing.T) { require.NoError(t, err) var clusterExtensions = []*ocv1alpha1.ClusterExtension{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "plainv0", - }, - Spec: ocv1alpha1.ClusterExtensionSpec{ - PackageName: os.Getenv("PLAIN_PKG_NAME"), - InstallNamespace: "default", - }, - }, { ObjectMeta: metav1.ObjectMeta{ Name: "registryv1", diff --git a/test/extension-developer-e2e/setup.sh b/test/extension-developer-e2e/setup.sh index d6fb74894..81682ebfe 100755 --- a/test/extension-developer-e2e/setup.sh +++ b/test/extension-developer-e2e/setup.sh @@ -8,13 +8,11 @@ help="setup.sh is used to build extensions using the operator-sdk and build the image + bundle image, and create a FBC image for the following bundle formats: - registry+v1 -- plain+v0 This script will ensure that all images built are loaded onto a KinD cluster with the name specified in the arguments. The following environment variables are required for configuring this script: -- \$CATALOG_IMG - the tag for the catalog image that contains the plain+v0 and registry+v1 bundle. +- \$CATALOG_IMG - the tag for the catalog image that contains the registry+v1 bundle. - \$REG_PKG_NAME - the name of the package for the extension that uses the registry+v1 bundle format. -- \$PLAIN_PKG_NAME - the name of the package for the extension that uses the plain+v0 bundle format. setup.sh also takes 5 arguments. Usage: @@ -43,12 +41,6 @@ if [[ -z "${REG_PKG_NAME}" ]]; then exit 1 fi -if [[ -z "${PLAIN_PKG_NAME}" ]]; then - echo "\$PLAIN_PKG_NAME is required to be set" - echo "${help}" - exit 1 -fi - ######################################## # Setup temp dir and local variables ######################################## @@ -62,9 +54,6 @@ DOMAIN=oc-opdev-e2e.operatorframework.io REG_DIR="${TMP_ROOT}/registry" mkdir -p "${REG_DIR}" -PLAIN_DIR="${TMP_ROOT}/plain" -mkdir -p "${PLAIN_DIR}" - operator_sdk=$1 container_tool=$2 kustomize=$3 @@ -74,12 +63,9 @@ namespace=$6 reg_img="${DOMAIN}/registry:v0.0.1" reg_bundle_img="${DOMAIN}/registry-bundle:v0.0.1" -plain_img="${DOMAIN}/plain:v0.0.1" -plain_bundle_img="${DOMAIN}/plain-bundle:v0.0.1" catalog_img="${CATALOG_IMG}" reg_pkg_name="${REG_PKG_NAME}" -plain_pkg_name="${PLAIN_PKG_NAME}" ######################################## # Create the registry+v1 based extension @@ -104,39 +90,10 @@ plain_pkg_name="${PLAIN_PKG_NAME}" $kind load docker-image "${reg_img}" --name "${kcluster_name}" $kind load docker-image "${reg_bundle_img}" --name "${kcluster_name}" -##################################### -# Create the plain+v0 based extension -# and build + load images -##################################### - -( - cd "${PLAIN_DIR}" && \ - $operator_sdk init --domain="${DOMAIN}" && \ - $operator_sdk create api \ - --group="${DOMAIN}" \ - --version v1alpha1 \ - --kind Plain \ - --resource --controller && \ - make generate manifests && \ - make docker-build IMG="${plain_img}" - mkdir -p manifests && \ - $kustomize build config/default > manifests/manifests.yaml -) - -cat << EOF > "${PLAIN_DIR}"/plainbundle.Dockerfile -FROM scratch -ADD manifests /manifests -EOF - -$container_tool build -t "${plain_bundle_img}" -f "${PLAIN_DIR}"/plainbundle.Dockerfile "${PLAIN_DIR}"/ - -$kind load docker-image "${plain_img}" --name "${kcluster_name}" -$kind load docker-image "${plain_bundle_img}" --name "${kcluster_name}" - -##################################### -# Create the FBC that contains both -# the plain+v0 and registry+v1 extensions -##################################### +############################### +# Create the FBC that contains +# the registry+v1 extensions +############################### cat << EOF > "${TMP_ROOT}"/catalog.Dockerfile FROM scratch @@ -175,39 +132,6 @@ cat < "${TMP_ROOT}"/catalog/index.yaml } ] } -{ - "schema": "olm.package", - "name": "${plain_pkg_name}" -} -{ - "schema": "olm.bundle", - "name": "${plain_pkg_name}.v0.0.1", - "package": "${plain_pkg_name}", - "image": "$plain_bundle_img", - "properties": [ - { - "type": "olm.package", - "value": { - "packageName": "${plain_pkg_name}", - "version": "0.0.1" - } - }, - { - "type": "olm.bundle.mediatype", - "value": "plain+v0" - } - ] -} -{ - "schema": "olm.channel", - "name": "preview", - "package": "${plain_pkg_name}", - "entries": [ - { - "name": "${plain_pkg_name}.v0.0.1" - } - ] -} EOF # Add a .indexignore to make catalogd ignore @@ -262,4 +186,3 @@ kubectl wait --for=condition=Complete -n "${namespace}" jobs/kaniko --timeout=60 # don't have write permissions so they can't be removed unless # we ensure they have the write permissions chmod -R +w "${REG_DIR}/bin" -chmod -R +w "${PLAIN_DIR}/bin" diff --git a/testdata/bundles/plain-v0/plain.v0.1.0/Dockerfile b/testdata/bundles/plain-v0/plain.v0.1.0/Dockerfile deleted file mode 100644 index bd54f66e6..000000000 --- a/testdata/bundles/plain-v0/plain.v0.1.0/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM scratch -COPY manifests /manifests \ No newline at end of file diff --git a/testdata/bundles/plain-v0/plain.v0.1.0/manifests/configmap.yaml b/testdata/bundles/plain-v0/plain.v0.1.0/manifests/configmap.yaml deleted file mode 100644 index 268033efa..000000000 --- a/testdata/bundles/plain-v0/plain.v0.1.0/manifests/configmap.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# This configmap was pulled straight from the Kubernetes docs -# and can be found at https://kubernetes.io/docs/concepts/configuration/configmap/ -apiVersion: v1 -kind: ConfigMap -metadata: - name: game-demo -data: - # property-like keys; each key maps to a simple value - player_initial_lives: "3" - ui_properties_file_name: "user-interface.properties" - - # file-like keys - game.properties: | - enemy.types=aliens,monsters - player.maximum-lives=5 - user-interface.properties: | - color.good=purple - color.bad=yellow - allow.textmode=true \ No newline at end of file diff --git a/testdata/catalogs/test-catalog/catalog.yaml b/testdata/catalogs/test-catalog/catalog.yaml index c219cb228..f96a53fa1 100644 --- a/testdata/catalogs/test-catalog/catalog.yaml +++ b/testdata/catalogs/test-catalog/catalog.yaml @@ -59,26 +59,4 @@ properties: - type: olm.package value: packageName: prometheus - version: 2.0.0 ---- -schema: olm.package -name: plain -defaultChannel: beta ---- -schema: olm.channel -name: beta -package: plain -entries: - - name: plain.0.1.0 ---- -schema: olm.bundle -name: plain.0.1.0 -package: plain -image: localhost/testdata/bundles/plain-v0/plain:v0.1.0 -properties: - - type: olm.package - value: - packageName: plain - version: 0.1.0 - - type: olm.bundle.mediatype - value: plain+v0 + version: 2.0.0 \ No newline at end of file