Skip to content

opm add with the options --from-index and --mode semver is not creating replaces edges #867

@camilamacedo86

Description

@camilamacedo86

Description

By using OPM index add --mode semver, the OPM CLI draws replaces edges to form a linear chain between versions based on semver ordering. We can use the command opm alpha list bundles quay.io/operatorhubio/catalog:latest <package-name> to check it.

All works fine if we create an index from scratch and add the bundles with the option --mode semver. However, it does not draw the replaces edges when the option --from-index is used. Note that when the bundles are added using the option --from-index is and we list the bundles, we can check the skips instead of replaces, see:

$ opm alpha list bundles quay.io/openshift-community-operators/catalog:v4.9 cert-manager
 WARN[0002] DEPRECATION NOTICE:
 Sqlite-based catalogs and their related subcommands are deprecated. Support for
 them will be removed in a future release. Please migrate your catalog workflows
 to the new file-based catalog format.
 PACKAGE CHANNEL BUNDLE REPLACES SKIPS SKIP RANGE IMAGE
 cert-manager stable cert-manager.v1.4.0 quay.io/openshift-community-operators/cert-manager:v1.4.0
 cert-manager stable cert-manager.v1.4.1 cert-manager.v1.4.0 quay.io/openshift-community-operators/cert-manager:v1.4.1
 cert-manager stable cert-manager.v1.4.2 cert-manager.v1.4.1 quay.io/openshift-community-operators/cert-manager:v1.4.2
 cert-manager stable cert-manager.v1.4.3 cert-manager.v1.4.2 quay.io/openshift-community-operators/cert-manager:v1.4.3
 cert-manager stable cert-manager.v1.4.4 cert-manager.v1.4.3 quay.io/openshift-community-operators/cert-manager:v1.4.4
 cert-manager stable cert-manager.v1.5.3 cert-manager.v1.4.4 quay.io/openshift-community-operators/cert-manager:v1.5.3
 cert-manager stable cert-manager.v1.5.4 cert-manager.v1.5.3 quay.io/openshift-community-operators/cert-manager:v1.5.4
 cert-manager stable cert-manager.v1.6.0 cert-manager.v1.5.4 quay.io/openshift-community-operators/cert-manager:v1.6.0
 cert-manager stable cert-manager.v1.6.1 cert-manager.v1.6.0 quay.io/openshift-community-operators/cert-manager:v1.6.1

How to reproduce

  1. Copy the registry.redhat.io/redhat/community-operator-index to tmp location
skopeo copy registry.redhat.io/redhat/community-operator-index:v4.9 docker://quay.io/operator_testing/xxx:latest
  1. Remove the package cert-manager and publish the tmp image
opm index rm --operators cert-manager -t quay.io/operator_testing/xxx:latest -c docker --from-index quay.io/operator_testing/xxx:latest
docker push quay.io/operator_testing/xxx:latest
  1. Add all bundles with the index-from and --mode semver options
opm index add --bundles quay.io/openshift-community-operators/cert-manager:v1.4.0,quay.io/openshift-community-operators/cert-manager:v1.4.1,quay.io/openshift-community-operators/cert-manager:v1.4.2,quay.io/openshift-community-operators/cert-manager:v1.4.3,quay.io/openshift-community-operators/cert-manager:v1.4.4,quay.io/openshift-community-operators/cert-manager:v1.5.3,quay.io/openshift-community-operators/cert-manager:v1.5.4,quay.io/openshift-community-operators/cert-manager:v1.6.0,quay.io/openshift-community-operators/cert-manager:v1.6.1 -t quay.io/operator_testing/xxx:latest --mode semver -c docker --from-index quay.io/operator_testing/xxx:latest
docker push quay.io/operator_testing/xxx:latest
  1. Run the command to list the bundles
./opm alpha list bundles quay.io/operator_testing/xxx:latest cert-manager
ubuntu@ip-172-31-29-117:~$ ./opm alpha list bundles quay.io/operator_testing/xxx:latest cert-manager
WARN[0005] DEPRECATION NOTICE:
Sqlite-based catalogs and their related subcommands are deprecated. Support for
them will be removed in a future release. Please migrate your catalog workflows
to the new file-based catalog format. 
PACKAGE       CHANNEL  BUNDLE               REPLACES  SKIPS                SKIP RANGE  IMAGE
cert-manager  stable   cert-manager.v1.4.0                                             quay.io/openshift-community-operators/cert-manager:v1.4.0
cert-manager  stable   cert-manager.v1.4.1            cert-manager.v1.4.0              quay.io/openshift-community-operators/cert-manager:v1.4.1
cert-manager  stable   cert-manager.v1.4.2            cert-manager.v1.4.1              quay.io/openshift-community-operators/cert-manager:v1.4.2
cert-manager  stable   cert-manager.v1.4.3            cert-manager.v1.4.2              quay.io/openshift-community-operators/cert-manager:v1.4.3
cert-manager  stable   cert-manager.v1.4.4            cert-manager.v1.4.3              quay.io/openshift-community-operators/cert-manager:v1.4.4
cert-manager  stable   cert-manager.v1.5.3            cert-manager.v1.4.4              quay.io/openshift-community-operators/cert-manager:v1.5.3
cert-manager  stable   cert-manager.v1.5.4            cert-manager.v1.5.3              quay.io/openshift-community-operators/cert-manager:v1.5.4
cert-manager  stable   cert-manager.v1.6.0            cert-manager.v1.5.4              quay.io/openshift-community-operators/cert-manager:v1.6.0
cert-manager  stable   cert-manager.v1.6.1            cert-manager.v1.6.0              quay.io/openshift-community-operators/cert-manager:v1.6.1

What is the consequence of this issue?

OLM is unable to upgrade the Operators distributed, which ought to use the semver mode.

Operator bundles distributed on community repos:

which are configured to use the semver mode ( see an e.g.: https://github.com/k8s-operatorhub/community-operators/blob/main/operators/cert-manager/ci.yaml#L2) after being added with the option --mode semver are not with replaces edges as expected which do not allow them to be upgraded via OLM. See: k8s-operatorhub/community-operators#119

The tests can be done with cert-manager (https://github.com/k8s-operatorhub/community-operators/blob/main/operators/cert-manager/ci.yaml#L2);

Opm version

1.19.1

Aditional Context

  • By speaking with @joelanford he was also able to reproduce it with the opm registry commands
  • He also checks the code, and he believes that the problem here is:
    So, by creating a DB from scratch, minDepth is 1, and ListBundles works correctly.
    However, when we use the flag -from-index, an existent index, where any channel in the catalog has a depth of 0, this problem will happen, which shows that the semver graph builder starts initial depth at one and not 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions