Bug 1917522

Summary: Deprecate --filter-by-os in oc adm catalog mirror
Product: OpenShift Container Platform Reporter: Evan Cordell <ecordell>
Component: OLMAssignee: Evan Cordell <ecordell>
OLM sub component: OLM QA Contact: Jian Zhang <jiazha>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: medium    
Version: 4.7   
Target Milestone: ---   
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:54:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Evan Cordell 2021-01-18 16:09:15 UTC
`--filter-by-os` should be deprecated in favor of `--index-filter-by-os` to better indicate that `oc adm catalog mirror` does not filter the images that are contained within the catalog.

Currently the contents are not filtered, because multiarch images are referenced by digest in the catalog, and filtering them down will change their digests. Registries do not support mirroring a manifestlist with some of its referenced manifests missing.

Comment 2 Jian Zhang 2021-01-21 02:32:27 UTC
[root@preserve-olm-env data]# ./oc version -o yaml
clientVersion:
  buildDate: "2021-01-21T00:15:43Z"
  compiler: gc
  gitCommit: 6f8f260853ad23a1edeb7ee622da764e6b711e37
  gitTreeState: clean
  gitVersion: 4.7.0-202101202207.p0-6f8f260
  goVersion: go1.15.5
  major: ""
  minor: ""
  platform: linux/amd64
releaseClientVersion: 4.7.0-0.nightly-2021-01-21-012810
...

1, --filter-by-os has been removed.
[root@preserve-olm-env data]# ./oc adm catalog mirror --help
Mirrors the contents of a catalog into a registry.
...
      --index-filter-by-os='': A regular expression to control which index image is picked when multiple variants are
available. Images will be passed as '<platform>/<architecture>[/<variant>]'. This does not apply to images referenced by
the index.

2, --index-filter-by-os works well.
[root@preserve-olm-env data]# ./oc adm catalog mirror --index-filter-by-os='linux/amd64'  registry.redhat.io/redhat/redhat-operator-index:v4.6 localhost:5000 --manifests-only
src image has index label for database path: /database/index.db
using database path mapping: /database/index.db:/tmp/982999206
W0121 02:12:59.201783     622 manifest.go:440] Chose linux/amd64 manifest from the manifest list.
wrote database to /tmp/982999206
using database at: /tmp/982999206/index.db
no digest mapping available for registry.redhat.io/container-native-virtualization/kubevirt-ssp-operator:v2.2.0-24, skip writing to ImageContentSourcePolicy
...
wrote mirroring manifests to manifests-redhat-operator-index-1611195172
[root@preserve-olm-env data]# tree manifests-redhat-operator-index-1611195172
manifests-redhat-operator-index-1611195172
├── catalogSource.yaml
├── imageContentSourcePolicy.yaml
└── mapping.txt

0 directories, 3 files
[root@preserve-olm-env data]# cat manifests-redhat-operator-index-1611195172/catalogSource.yaml 
apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: redhat-operator-index
  namespace: openshift-marketplace
spec:
  image: localhost:5000/redhat/redhat-operator-index:v4.6
  sourceType: grpc


[root@preserve-olm-env data]# cat manifests-redhat-operator-index-1611195172/imageContentSourcePolicy.yaml 
apiVersion: operator.openshift.io/v1alpha1
kind: ImageContentSourcePolicy
metadata:
  name: redhat-operator-index
spec:
  repositoryDigestMirrors:
  - mirrors:
    - localhost:5000/openshift-serverless-1-tech-preview/serving-controller-rhel8
    source: registry.redhat.io/openshift-serverless-1-tech-preview/serving-controller-rhel8
  - mirrors:
    - localhost:5000/rhscl/postgresql-96-rhel7
    source: registry.redhat.io/rhscl/postgresql-96-rhel7
...

[root@preserve-olm-env data]# cat manifests-redhat-operator-index-1611195172/mapping.txt 
registry.redhat.io/rhacm2/mcm-topology-rhel8@sha256:2b453e23ad8c6af0a2705f1e423aa5746574b6c3dca0d8130fdd60d076023d43=localhost:5000/rhacm2/mcm-topology-rhel8:1f21c843
registry.redhat.io/codeready-workspaces/pluginregistry-rhel8@sha256:e2f865550b46ead535c4b6cd8204889957e3bbc73300ad8af4e4e6a570249477=localhost:5000/codeready-workspaces/pluginregistry-rhel8:4673d8e1
...

Looks good to me, verify it.

Comment 5 errata-xmlrpc 2021-02-24 15:54:15 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.7.0 security, bug fix, and enhancement 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-2020:5633