oc-mirror requires that an operator's default channel is included in the ImageSetConfiguration
Environment
- OpenShift Container Platform 4.x
- oc-mirror plugin
Issue
-
Is it possible to not mirror the default channel of an operator when using oc-mirror?
-
When using an older version of oc-mirror, the following error is shown:
The rendered catalog is invalid. Run "oc-mirror list operators --catalog CATALOG-NAME --package PACKAGE-NAME" for more information. Please check the minVersion, maxVersion, and default channel for each invalid package. error: error converting declarative config to include config: invalid index: └── invalid package "example-operator": └── invalid channel "stable": └── channel must contain at least one bundle -
When using a newer version of oc-mirror, an error similar to the following is shown:
The current default channel was not valid, so an attempt was made to automatically assign a new default channel, which has failed. The failure occurred because none of the remaining channels contain a "olm.channel" priority property, so it was not possible to establish a channel to use as the default channel. This can be resolved by one of the following changes: 1) assign a "olm.channel" property on the appropriate channels to establish a channel priority 2) modify the default channel manually in the catalog 3) by changing the ImageSetConfiguration to filter channels or packages in such as way that it will include a package version that exists in the current default channel The rendered catalog is invalid. Run "oc-mirror list operators --catalog CATALOG-NAME --package PACKAGE-NAME" for more information. error: error generating diff: the current default channel "latest" for package "example-operator" could not be determined... ensure that your ImageSetConfiguration filtering criteria results in a package version that exists in the current default channel
Resolution
-
Use a version of
oc-mirrorthat is at least as new as the one provided by:- 4.15.13
-
Add a new
defaultChannel: DESIRED_DEFAULT_CHANNELproperty to the appropriate dict in themirror.operators.[].packageslist, e.g.:kind: ImageSetConfiguration mirror: operators: - catalog: registry.redhat.io/redhat/redhat-operator-index:v4.14 packages: - name: advanced-cluster-management # The new property to add: # Set the desired defaultChannel below. This will override the existing defaultChannel. defaultChannel: release-2.8 # Assuming the real default channel is something else like "release-2.9", # this imageSetConfig will fail without the above line channels: - name: release-2.8
Root Cause
There must always be a default channel, but prior to oc-mirror versions 4.12.51, 4.13.34, 4.14.12, & 4.15.0, there was no way to customize the default channel; hence, the package default had to always be included. Using the above ACM example (at a time when release-2.9 was the default channel), this would mean specifying & syncing both the release-2.8 and release-2.9 channels, even if 2.9 was not needed or desired.
From the OCP 4.15 Release notes:
Previously, to filter operator packages by channel, for example,
mirror.operators.catalog.packages.channels, you had to specify the default channel for the package, even if you did not intend to use the packages from that channel. Based on this information, the resulting catalog is considered invalid if the imageSetConfig does not contain the default channel for the package.This update introduces the
defaultChannelfield in themirror.operators.catalog.packagessection. You can now select a default channel. This action enables oc-mirror to build a new catalog that defines the selected channel in thedefaultChannelfield as the default for the package. (This content is not included.OCPBUGS-385)
Unfortunately, that initial release of this feature (in 4.15.0 and the above-mentioned versions) had a critical flaw (ref This content is not included.OCPBUGS-33305) which wasn't resolved until the 4.15.13 release of oc-mirror.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.