Description of problem: The bundles' images that generated by "operator-sdk pkgman-to-bundle" won't be installed success if the version is not the latest version. Like operator ditto has three versions:"0.1.0, 0.1.1, 0.2.0".Operator-sdk command will generate 3 bundles, but only the bundle 0.2.0 can be installed success on ocp cluster. Version-Release number of selected component (if applicable): operator-sdk version: "v1.8.0-ocp", commit: "ad24ac6152de624270e9bf64a61ef40dd281c5b2", kubernetes version: "v1.20.2", go version: "go1.16.4", GOOS: "linux", GOARCH: "amd64" How reproducible: always Steps to Reproduce: 1.use the community operators to generate the bundles:https://github.com/operator-framework/community-operators/tree/master/community-operators/ditto-operator $tree ditto-operator ditto-operator ├── 0.1.0 │ ├── ditto-operator.v0.1.0.clusterserviceversion.yaml │ └── ditto.yaml ├── 0.1.1 │ ├── ditto-operator.v0.1.1.clusterserviceversion.yaml │ └── ditto.yaml ├── 0.2.0 │ ├── ditto-operator.v0.2.0.clusterserviceversion.yaml │ └── ditto.yaml ├── ci.yaml └── ditto-operator.package.yaml 2.$operator-sdk pkgman-to-bundle ditto-operator --image-tag-base quay.io/xxxxx/ditto-operator-bundle INFO[0000] Packagemanifests will be migrated to bundles in bundles directory INFO[0000] Supported channels cannot be identified from CSV ditto-operator.v0.1.0, using default channel 'preview' INFO[0000] Creating bundles/bundle-0.1.0/bundle.Dockerfile INFO[0000] Creating bundles/bundle-0.1.0/metadata/annotations.yaml INFO[0000] Bundle metadata generated suceessfully INFO[0001] Successfully built image quay.io/xxxxx/ditto-operator-bundle:0.1.0 INFO[0001] Supported channels cannot be identified from CSV ditto-operator.v0.1.1, using default channel 'preview' INFO[0001] Creating bundles/bundle-0.1.1/bundle.Dockerfile INFO[0001] Creating bundles/bundle-0.1.1/metadata/annotations.yaml INFO[0001] Bundle metadata generated suceessfully INFO[0002] Successfully built image quay.io/xxxxx/ditto-operator-bundle:0.1.1 INFO[0002] Creating bundles/bundle-0.2.0/bundle.Dockerfile INFO[0002] Creating bundles/bundle-0.2.0/metadata/annotations.yaml INFO[0002] Bundle metadata generated suceessfully INFO[0004] Successfully built image quay.io/xxxxx/ditto-operator-bundle:0.2.0 3.$run bundle quay.io/xxxxx/ditto-operator-bundle:0.1.0 Actual results: 1. failed to run bundle $run bundle quay.io/xxxxx/ditto-operator-bundle:0.1.0 INFO[0023] Successfully created registry pod: quay-io-xxxxx-ditto-operator-bundle-0-1-0 INFO[0023] Created CatalogSource: ditto-operator-catalog INFO[0024] OperatorGroup "operator-sdk-og" created INFO[0024] Created Subscription: ditto-operator-v0-1-0-sub FATA[0122] Failed to run bundle: install plan is not available for the subscription ditto-operator-v0-1-0-sub: Get "https://api.w-aw.qe.devcluster.openshift.com:6443/apis/operators.coreos.com/v1alpha1/namespaces/default/subscriptions/ditto-operator-v0-1-0-sub": context deadline exceeded 2.The logs of registry pod $oc logs quay-io-olmqe-ditto-operator-bundle-0-1-0 time="2021-07-06T07:23:01Z" level=info msg="adding to the registry" bundles="[quay.io/olmqe/ditto-operator-bundle:0.1.0]" time="2021-07-06T07:23:02Z" level=info msg="Could not find optional dependencies file" dir=bundle_tmp015136050 file=bundle_tmp015136050/metadata load=annotations time="2021-07-06T07:23:02Z" level=info msg="found csv, loading bundle" dir=bundle_tmp015136050 file=bundle_tmp015136050/manifests load=bundle time="2021-07-06T07:23:02Z" level=info msg="loading bundle file" dir=bundle_tmp015136050/manifests file=ditto-operator.v0.1.0.clusterserviceversion.yaml load=bundle time="2021-07-06T07:23:02Z" level=info msg="loading bundle file" dir=bundle_tmp015136050/manifests file=ditto.yaml load=bundle time="2021-07-06T07:23:02Z" level=error msg="permissive mode disabled" bundles="[quay.io/olmqe/ditto-operator-bundle:0.1.0]" error="error loading bundle into db: FOREIGN KEY constraint failed" Error: error loading bundle into db: FOREIGN KEY constraint failed Usage: opm registry add [flags] Expected results: The bundle could be installed success Additional info: The bundle can be installed success if it is generated by OPM 1)$opm alpha bundle build -c alpha -e alpha -d 0.1.0 -p ditto-operator -t quay.io/olmqe/ditto-operator-bundle:0.1.0 -o=true 2)$opm version Version: version.Version{OpmVersion:"v1.15.4-14-g5ccabf95", GitCommit:"5ccabf956d25a2788cc64ad5591c404d7b950207", BuildDate:"2021-06-01T18:08:08Z", GoOs:"linux", GoArch:"amd64"} 3)$operator-sdk run bundle quay.io/olmqe/ditto-operator:0.1.0 INFO[0022] Successfully created registry pod: quay-io-olmqe-ditto-operator-0-1-0 INFO[0023] Created CatalogSource: ditto-operator-catalog INFO[0023] OperatorGroup "operator-sdk-og" created INFO[0023] Created Subscription: ditto-operator-v0-1-0-sub INFO[0026] Approved InstallPlan install-qrsp7 for the Subscription: ditto-operator-v0-1-0-sub INFO[0026] Waiting for ClusterServiceVersion "default/ditto-operator.v0.1.0" to reach 'Succeeded' phase INFO[0026] Waiting for ClusterServiceVersion "default/ditto-operator.v0.1.0" to appear INFO[0035] Found ClusterServiceVersion "default/ditto-operator.v0.1.0" phase: Installing INFO[0046] Found ClusterServiceVersion "default/ditto-operator.v0.1.0" phase: Succeeded INFO[0046] OLM has successfully installed "ditto-operator.v0.1.0"
@Jia Fan With https://github.com/operator-framework/operator-sdk/pull/4964, one can select the bundle version which they want to and deploy it. They can further copy the version of bundle which they want to run in the project's root directory and run it. However the `FROEIGN KEY constraint` seems to be an error with the `run bundle`. Based on another bugzilla which was opened related to this (https://bugzilla.redhat.com/show_bug.cgi?id=1883377), looks like the issue has been solved. Reference on running bundles with plgman-to-bundle command by copying them to project's root dir: https://sdk.operatorframework.io/docs/olm-integration/quickstart-package-manifests/#migrating-packagemanifests-to-bundles
(In reply to Varsha from comment #1) > @Jia Fan With https://github.com/operator-framework/operator-sdk/pull/4964, > one can select the bundle version which they want to and deploy it. They can > further copy the version of bundle which they want to run in the project's > root directory and run it. However the `FROEIGN KEY constraint` seems to be > an error with the `run bundle`. Based on another bugzilla which was opened > related to this (https://bugzilla.redhat.com/show_bug.cgi?id=1883377), looks > like the issue has been solved. > > Reference on running bundles with plgman-to-bundle command by copying them > to project's root dir: > https://sdk.operatorframework.io/docs/olm-integration/quickstart-package- > manifests/#migrating-packagemanifests-to-bundles Yes, Varsha. The latest "opm" doesn't have the same problem. But the default index image for `operator-sdk run bundle` is "quay.io/operator-framework/upstream-opm-builder:latest". And the problem still exists for "operator-sdk".
This bug seems to be similar to https://bugzilla.redhat.com/show_bug.cgi?id=1979506&GoAheadAndLogIn=1. This PR: https://github.com/operator-framework/operator-sdk/pull/5062 solves the issue.
This was fixed in release-4.9: https://github.com/openshift/ocp-release-operator-sdk/pull/141/commits/d7b4ad12d51564e84d0ced3c5d543f0e4a148720