Bug 1989460 - non-head bundle of the channel is included in output of opm alpha diff for heads-only mode
Summary: non-head bundle of the channel is included in output of opm alpha diff for he...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: OLM
Version: 4.9
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.9.0
Assignee: Eric Stroczynski
QA Contact: kuiwang
URL: https://github.com/openshift/operator...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-08-03 09:29 UTC by kuiwang
Modified: 2021-10-18 17:44 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-10-18 17:44:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift operator-framework-olm pull 161 0 None None None 2021-08-11 20:37:00 UTC
Red Hat Product Errata RHSA-2021:3759 0 None None None 2021-10-18 17:44:18 UTC

Description kuiwang 2021-08-03 09:29:37 UTC
Description of problem:
For heads-only mode, the output only includes the head of the channel of package.

For example, we have catalog which includes mta and cockroachdb packages.
for mta, it has two channels
    alpha: 0.0.5 -> 0.0.4
    beta: 0.0.3 -> 0.0.2

for cockroachdb, it has only one channel
    stable: 5.0.4

For output, we expect :
for mta, 
    alpha: 0.0.5
    beta: 0.0.3

for cockroachdb, 
    stable: 5.0.4

but 0.0.2 is included in beta and 0.0.4 is includes alpha.

Version-Release number of selected component (if applicable):
[root@preserve-olm-env OSDK-1869]# opm version
Version: version.Version{OpmVersion:"cf7140bf3", GitCommit:"cf7140bf3c404454892c9c972b0d9e839a46f619", BuildDate:"2021-08-02T05:12:33Z", GoOs:"linux", GoArch:"amd64"}

How reproducible:
Always


Steps to Reproduce:
1. follow http://pastebin.test.redhat.com/984112 to make index image

2. opm alpha diff quay.io/kuiwang/olm-index:OLM-1869-head -o json > heads-onlh-diff.json

3. check the output. Note: in order to reduce data szie, I cut out it.
[root@preserve-olm-env OSDK-1869]# cat heads-onlh-diff.json
{
    "schema": "olm.package",
    "name": "cockroachdb",
    "defaultChannel": "stable",
    "icon": {
        "base64data": "PHN",
        "mediatype": "image/svg+xml"
    }
}
{
    "schema": "olm.bundle",
    "name": "cockroachdb.v5.0.4",
    "package": "cockroachdb",
    "image": "quay.io/olmqe/cockroachdb-operator:5.0.4-1869",
    "properties": [
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhc"
            }
        },
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhc"
            }
        },
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhc"
            }
        },
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhc"
            }
        },
        {
            "type": "olm.channel",
            "value": {
                "name": "stable"
            }
        },
        {
            "type": "olm.gvk",
            "value": {
                "group": "charts.operatorhub.io",
                "kind": "Cockroachdb",
                "version": "v1alpha1"
            }
        },
        {
            "type": "olm.package",
            "value": {
                "packageName": "cockroachdb",
                "version": "5.0.4"
            }
        },
        {
            "type": "olm.package.required",
            "value": {
                "packageName": "mta-operator",
                "versionRange": "0.0.5"
            }
        }
    ],
    "relatedImages": [
        {
            "name": "",
            "image": "quay.io/olmqe/cockroachdb-operator:5.0.4-1869"
        },
        {
            "name": "",
            "image": "gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0"
        },
        {
            "name": "",
            "image": "quay.io/helmoperators/cockroachdb:v5.0.4"
        }
    ]
}
{
    "schema": "olm.package",
    "name": "mta-operator",
    "defaultChannel": "beta",
    "icon": {
        "base64data": "iVBOR",
        "mediatype": "image/png"
    }
}
{
    "schema": "olm.bundle",
    "name": "windup-operator.0.0.2",
    "package": "mta-operator",
    "image": "quay.io/olmqe/mta-operator:v0.0.2-1869",
    "properties": [
        {
            "type": "olm.channel",
            "value": {
                "name": "beta"
            }
        },
        {
            "type": "olm.gvk",
            "value": {
                "group": "windup.jboss.org",
                "kind": "Windup",
                "version": "v1"
            }
        },
        {
            "type": "olm.package",
            "value": {
                "packageName": "mta-operator",
                "version": "0.0.2"
            }
        }
    ],
    "relatedImages": [
        {
            "name": "",
            "image": "quay.io/olmqe/mta-operator:v0.0.2-1869"
        },
        {
            "name": "",
            "image": "quay.io/windupeng/windup-operator-native:0.0.2"
        }
    ]
}
{
    "schema": "olm.bundle",
    "name": "windup-operator.0.0.3",
    "package": "mta-operator",
    "image": "quay.io/olmqe/mta-operator:v0.0.3-1869",
    "properties": [
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhcGl"
            }
        },
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhcGl"
            }
        },
        {
            "type": "olm.channel",
            "value": {
                "name": "beta",
                "replaces": "windup-operator.0.0.2"
            }
        },
        {
            "type": "olm.gvk",
            "value": {
                "group": "windup.jboss.org",
                "kind": "Windup",
                "version": "v1"
            }
        },
        {
            "type": "olm.package",
            "value": {
                "packageName": "mta-operator",
                "version": "0.0.3"
            }
        }
    ],
    "relatedImages": [
        {
            "name": "",
            "image": "quay.io/olmqe/mta-operator:v0.0.3-1869"
        },
        {
            "name": "",
            "image": "quay.io/windupeng/windup-operator-native:0.0.3"
        }
    ]
}
{
    "schema": "olm.bundle",
    "name": "windup-operator.0.0.4",
    "package": "mta-operator",
    "image": "quay.io/olmqe/mta-operator:v0.0.4-1869",
    "properties": [
        {
            "type": "olm.channel",
            "value": {
                "name": "alpha"
            }
        },
        {
            "type": "olm.gvk",
            "value": {
                "group": "windup.jboss.org",
                "kind": "Windup",
                "version": "v1"
            }
        },
        {
            "type": "olm.package",
            "value": {
                "packageName": "mta-operator",
                "version": "0.0.4"
            }
        }
    ],
    "relatedImages": [
        {
            "name": "",
            "image": "quay.io/olmqe/mta-operator:v0.0.4-1869"
        },
        {
            "name": "",
            "image": "quay.io/windupeng/windup-operator-native:0.0.4"
        }
    ]
}
{
    "schema": "olm.bundle",
    "name": "windup-operator.0.0.5",
    "package": "mta-operator",
    "image": "quay.io/olmqe/mta-operator:v0.0.5-1869",
    "properties": [
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhcGl"
            }
        },
        {
            "type": "olm.bundle.object",
            "value": {
                "data": "eyJhcGl"
            }
        },
        {
            "type": "olm.channel",
            "value": {
                "name": "alpha",
                "replaces": "windup-operator.0.0.4"
            }
        },
        {
            "type": "olm.gvk",
            "value": {
                "group": "windup.jboss.org",
                "kind": "Windup",
                "version": "v1"
            }
        },
        {
            "type": "olm.package",
            "value": {
                "packageName": "mta-operator",
                "version": "0.0.5"
            }
        }
    ],
    "relatedImages": [
        {
            "name": "",
            "image": "quay.io/olmqe/mta-operator:v0.0.5-1869"
        },
        {
            "name": "",
            "image": "quay.io/windupeng/windup-operator-native:0.0.5"
        }
    ]
}
[root@preserve-olm-env OSDK-1869]# cat heads-onlh-diff.json|jq .name
"cockroachdb"
"cockroachdb.v5.0.4"
"mta-operator"
"windup-operator.0.0.2"
"windup-operator.0.0.3"
"windup-operator.0.0.4"
"windup-operator.0.0.5"
[root@preserve-olm-env OSDK-1869]# 


Actual results:
non-head bunlde is outputed for heads-only mode

Expected results:
only head bunlde is outputed for heads-only mode

Additional info:

Comment 1 Eric Stroczynski 2021-08-05 01:00:22 UTC
This is not a "bug" per-se, but a TODO. As of now, an entire dependency's package will be added to the diff to ensure an upgrade graph exists between all dependency versions.
In this case, since cockroachdb is dependent on mta-operator, the entire mta-operator package is added to the diff. Soon these will be selectively added.

I've clarified this here: https://github.com/operator-framework/operator-registry/pull/740

Comment 2 kuiwang 2021-08-05 01:40:20 UTC
@estroczy,  Thanks for clarification.

Now https://github.com/operator-framework/operator-registry/pull/740 is in upstream and not merged.
Please make it merged in downsteam, ,and then I change it to Verified.

Thanks

Comment 3 kuiwang 2021-08-10 00:47:27 UTC
We need to the fix on downstream and then verify it.
Now the fix is not on downstream, so change it back to Assigned.

Comment 5 kuiwang 2021-08-16 01:39:22 UTC
verified. LGTM

---
[root@preserve-olm-env operator-framework-olm]# opm alpha diff --help
Diff a set of old and new catalog references ("refs") to produce a declarative config containing only packages channels, and versions not present in the old set, and versions that differ between the old and new sets. This is known as "latest" mode. These references are passed through 'opm render' to produce a single declarative config.

 This command has special behavior when old-refs are omitted, called "heads-only" mode: instead of the output being that of 'opm render refs...' (which would be the case given the preceding behavior description), only the channel heads of all channels in all packages are included in the output, and dependencies. Dependencies are assumed to be provided by either an old ref, in which case they are not included in the diff, or a new ref, in which case they are included. Dependencies provided by some catalog unknown to 'opm alpha diff' will not cause the command to error, but an error will occur if that catalog is not serving these dependencies at runtime.

 NOTE: for now, if any dependency exists, the entire dependency's package is added to the diff. In the future, these packages will be pruned such that only the latest dependencies satisfying a package version range or GVK, and their upgrade graph(s) to their latest channel head(s), are included in the diff.

Usage:
  opm alpha diff [old-refs]... new-refs... [flags]

Examples:
  # Diff a catalog at some old state and latest state into a declarative config index.
  mkdir -p catalog-index
  opm alpha diff registry.org/my-catalog:abc123 registry.org/my-catalog:def456 -o yaml > ./my-catalog-index/index.yaml
  
  # Build and push this index into an index image.
  opm alpha generate dockerfile ./my-catalog-index
  docker build -t registry.org/my-catalog:latest-abc123-def456 -f index.Dockerfile .
  docker push registry.org/my-catalog:latest-abc123-def456
  
  # Create a new catalog from the heads of an existing catalog, then build and push the image like above.
  opm alpha diff registry.org/my-catalog:def456 -o yaml > my-catalog-index/index.yaml
  docker build -t registry.org/my-catalog:headsonly-def456 -f index.Dockerfile .
  docker push registry.org/my-catalog:headsonly-def456

Flags:
      --ca-file string   the root Certificates to use with this command
      --debug            enable debug logging
  -h, --help             help for diff
  -o, --output string    Output format (json|yaml) (default "yaml")

Global Flags:
      --skip-tls   skip TLS certificate verification for container image registries while pulling bundles or index
[root@preserve-olm-env operator-framework-olm]# opm version
Version: version.Version{OpmVersion:"edcddea0f", GitCommit:"edcddea0f2b6344bc388b746078d6ae81dfbf1f8", BuildDate:"2021-08-16T01:32:12Z", GoOs:"linux", GoArch:"amd64"}
[root@preserve-olm-env operator-framework-olm]# 
---

Comment 8 errata-xmlrpc 2021-10-18 17:44:09 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.9.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:3759


Note You need to log in before you can comment on or make changes to this bug.