Bug 1810268

Summary: oc image mirror shouldn't default to mirroring manifest lists
Product: OpenShift Container Platform Reporter: Kevin Rizza <krizza>
Component: ocAssignee: Kevin Rizza <krizza>
Status: CLOSED ERRATA QA Contact: Bruno Andrade <bandrade>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.3.zCC: aos-bugs, jmalde, jokerman, mfojtik, nnosenzo, yinzhou
Target Milestone: ---   
Target Release: 4.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1810256
: 1810533 (view as bug list) Environment:
Last Closed: 2020-05-13 22:00:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1810256    
Bug Blocks: 1810533    

Description Kevin Rizza 2020-03-04 20:08:57 UTC
+++ This bug was initially created as a clone of Bug #1810256 +++

Description of problem:

With this pr https://github.com/openshift/oc/pull/298 we introduced a change to enable `oc adm catalog mirror` to force mirror manifest list digests. However, we also introduced the behavior that oc image mirror also always enables that force option with no method of disabling it.

`oc image mirror` should retain the old default behavior (oc image mirror doesn't mirror the manifest list if there is only a single image in the list) with two exceptions:

1. There should be an explicit option to force the manifest list mirroring (like `--force-manifest-list`)
2. If --filter-by-os is passed a wildcard (`--filter-by-os=.*`) it should forcefully mirror the manifestlist.


Version-Release number of selected component (if applicable):

4.5

How reproducible:

Always


Steps to Reproduce:
1. Run oc image mirror against a manifest list digest. Ex:

$ ./oc image mirror registry.redhat.io/openshift4/ose-sriov-network-webhook@sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d localhost:5000/kevinrizza/sriov:latest --dry-run


Actual results:

Manifest list was mirrored:

./oc image mirror registry.redhat.io/openshift4/ose-sriov-network-webhook@sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d localhost:5000/kevinrizza/sriov:latest --dry-run

localhost:5000/  
kevinrizza/sriov    
blobs:
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:455ea8ab06218495bbbcb14b750a0d644897b24f8c5dcf9e8698e27882583412 1.575KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:4377e81e5655f5852beea18997f4ff77d4f513b18d04587a275d30ea22874ae3 5.002KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:13be0effd90b69b59a7109cbb6133186be48c386dfb5a69e99965ad383451789 3.333MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:edf561fefe181b648d6502acfd17fd6a6bb8d378057dae272f36ffc850f65bf8 7.842MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:a27f668f2f9d1846948029fb27f6da2848e0764888c8f98b3f677035073a255d 8.893MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:bb13d92caffa705f32b8a7f9f661e07ddede310c6ccfa78fb53a49539740e29b 72.71MiB
    manifests:
      sha256:2288935e7d2e4c1653ecb287c35a0dda11dddd10f034d85c025b95219a5f37ee
      sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d
      sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d -> latest
  stats: shared=0 unique=6 size=92.78MiB ratio=1.00

phase 0:
  localhost:5000 kevinrizza/sriov blobs=6 mounts=0 manifests=3 shared=0

info: Planning completed in 1.75s
info: Dry run complete

Expected results:

Just the underlying container image digest was mirrored

Comment 3 Bruno Andrade 2020-03-09 03:20:11 UTC
Image mirror worked as expected. Marking as VERIFIED.

oc version
Client Version: 4.4.0-0.nightly-2020-03-06-141620

Steps used to reproduce.

1) Started a local registry as oriented on https://bugzilla.redhat.com/show_bug.cgi?id=1773821#c7 

2) oc image mirror -h has keep-manifest-list


 Options:
      --dir='': The directory on disk that file:// images will be copied under.
      --dry-run=false: Print the actions that would be taken and exit without writing to the destinations.
  -f, --filename=[]: One or more files to read SRC=DST or SRC DST [DST ...] mappings from.
      --filter-by-os='': A regular expression to control which images are considered when multiple variants are
available. Images will be passed as '<platform>/<architecture>[/<variant>]'.
      --force=false: Attempt to write all layers and manifests even if they exist in the remote repository.
      --from-dir='': The directory on disk that file:// images will be read from. Overrides --dir
      --insecure=false: Allow push and pull operations to registries to be made over HTTP
      --keep-manifest-list=false: If an image is part of a manifest list, always mirror the list even if only one image

3) Image mirror dry run:
oc image mirror registry.redhat.io/openshift4/ose-sriov-network-webhook@sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d localhost:5000/bandrade:1.0 --dry-run
localhost:5000/
  bandrade
    blobs:
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:455ea8ab06218495bbbcb14b750a0d644897b24f8c5dcf9e8698e27882583412 1.575KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:4377e81e5655f5852beea18997f4ff77d4f513b18d04587a275d30ea22874ae3 5.002KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:13be0effd90b69b59a7109cbb6133186be48c386dfb5a69e99965ad383451789 3.333MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:edf561fefe181b648d6502acfd17fd6a6bb8d378057dae272f36ffc850f65bf8 7.842MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:a27f668f2f9d1846948029fb27f6da2848e0764888c8f98b3f677035073a255d 8.893MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:bb13d92caffa705f32b8a7f9f661e07ddede310c6ccfa78fb53a49539740e29b 72.71MiB
    manifests:
      sha256:2288935e7d2e4c1653ecb287c35a0dda11dddd10f034d85c025b95219a5f37ee -> 1.0
  stats: shared=0 unique=6 size=92.78MiB ratio=1.00

phase 0:
  localhost:5000 bandrade blobs=6 mounts=0 manifests=1 shared=0

info: Planning completed in 3.51s
info: Dry run complete

4) Image mirror:
oc image mirror registry.redhat.io/openshift4/ose-sriov-network-webhook@sha256:d269ed4a4cbc5d8ecb2027891f2bd42ffaa61ce2785e38bd761ccbcd2d794c1d localhost:5000/bandrade:1.0 
localhost:5000/
  bandrade
    blobs:
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:455ea8ab06218495bbbcb14b750a0d644897b24f8c5dcf9e8698e27882583412 1.575KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:4377e81e5655f5852beea18997f4ff77d4f513b18d04587a275d30ea22874ae3 5.002KiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:13be0effd90b69b59a7109cbb6133186be48c386dfb5a69e99965ad383451789 3.333MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:edf561fefe181b648d6502acfd17fd6a6bb8d378057dae272f36ffc850f65bf8 7.842MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:a27f668f2f9d1846948029fb27f6da2848e0764888c8f98b3f677035073a255d 8.893MiB
      registry.redhat.io/openshift4/ose-sriov-network-webhook sha256:bb13d92caffa705f32b8a7f9f661e07ddede310c6ccfa78fb53a49539740e29b 72.71MiB
    manifests:
      sha256:2288935e7d2e4c1653ecb287c35a0dda11dddd10f034d85c025b95219a5f37ee -> 1.0
  stats: shared=0 unique=6 size=92.78MiB ratio=1.00

phase 0:
  localhost:5000 bandrade blobs=6 mounts=0 manifests=1 shared=0

info: Planning completed in 6.02s
uploading: localhost:5000/bandrade sha256:13be0effd90b69b59a7109cbb6133186be48c386dfb5a69e99965ad383451789 3.333MiB
uploading: localhost:5000/bandrade sha256:bb13d92caffa705f32b8a7f9f661e07ddede310c6ccfa78fb53a49539740e29b 72.71MiB
uploading: localhost:5000/bandrade sha256:edf561fefe181b648d6502acfd17fd6a6bb8d378057dae272f36ffc850f65bf8 7.842MiB
uploading: localhost:5000/bandrade sha256:a27f668f2f9d1846948029fb27f6da2848e0764888c8f98b3f677035073a255d 8.893MiB


info: Mirroring completed in 1m48.27s (1.25MB/s)

Comment 5 errata-xmlrpc 2020-05-13 22:00:37 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, 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/RHBA-2020:0581