Bug 2054911

Summary: oc image mirror --from-dir ignores --from-dir
Product: OpenShift Container Platform Reporter: John Marley <jmarley>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED NOTABUG QA Contact: zhou ying <yinzhou>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.8CC: aos-bugs, mfojtik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-16 23:53:29 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 John Marley 2022-02-16 01:20:10 UTC
Description of problem:

This is the same problem described in bug 1807807 which was supposedly fixed in 4.3.  Trying to mirror from a directory to a registry fails:

# oc image mirror -a ${LOCAL_SECRET_JSON} --from-dir=exportdir file://openshift/release:4.8.29* ${LOCAL_REGISTRY}/ocp4
error: you must specify at least one source image to pull and the destination to push to as SRC=DST or SRC DST [DST2 DST3 ...]

See the full output below.  It appears to be ignoring the --from-dir option.  I have tried full pathname and relative pathname with the same result.


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

4.8.29


How reproducible:

Always


Steps to Reproduce:
1. Run this command:

# oc image mirror --from-dir=/home/otjm452/mirror file://v2/openshift/release:4.8.29-* gitlab01.priv.support.energyq.net.au:5000/tivoli/openshift/ocp4/openshift --loglevel=5

2.
3.


Actual results:

I0216 11:07:02.352431   21500 config.go:128] looking for config.json at /root/.docker/config.json
I0216 11:07:02.352484   21500 config.go:94] looking for .dockercfg at /root/.dockercfg
I0216 11:07:02.352565   21500 file.go:30] Repository https://registry-1.docker.io v2/openshift/release
I0216 11:07:02.352608   21500 options.go:59] Search for "4.8.29-*" (^4\.8\.29-.*.*$) found: []
error: you must specify at least one source image to pull and the destination to push to as SRC=DST or SRC DST [DST2 DST3 ...]


Expected results:

Containers are pushed


Additional info:

Local mirror directory looks like:

# find ./mirror -print
./mirror
./mirror/config
./mirror/config/signature-sha256-9f9df3ff16e7ddd66.yaml
./mirror/v2/
./mirror/v2/openshift
./mirror/v2/openshift/release
./mirror/v2/openshift/release/blobs
./mirror/v2/openshift/release/blobs/sha256:ba60b...
...
./mirror/v2/openshift/release/manifests
./mirror/v2/openshift/release/manifests/sha256:3771...
./mirror/v2/openshift/release/manifests/4.8.29-x86_64-cluster-version-operator
./mirror/v2/openshift/release/manifests/4.8.29-x86_64-azure-disk-csi-driver-operator
..etc..

Comment 1 John Marley 2022-02-16 03:41:07 UTC
I've also tried these variations:

oc image mirror --from-dir=/home/otjm452/mirror file://openshift/release:4.8.29-* gitlab01.priv.support.energyq.net.au:5000/tivoli/openshift/ocp4/openshift --loglevel=5 

oc image mirror --from-dir=/home/otjm452/mirror file://openshift/release:4.8.29-* gitlab01.priv.support.energyq.net.au:5000/tivoli/openshift/ocp4/openshift --loglevel=5 --dir=notset

oc image mirror --dir=/home/otjm452/mirror file://openshift/release:4.8.29-* gitlab01.priv.support.energyq.net.au:5000/tivoli/openshift/ocp4/openshift --loglevel=5

oc image mirror --dir=/home/otjm452/mirror file://openshift/release:4.8.29-* gitlab01.priv.support.energyq.net.au:5000/tivoli/openshift/ocp4/openshift --loglevel=5 --from-dir=notset

all produce the same results.

I've also run it with strace and I can see it running newfstatat() against all the files under mirror/v2/openshift/release/manifests, but not the files under mirror/v2/openshift/release/blobs, so it looks like the mirror has files where they're expected.  It's just not matching the files.

Comment 2 John Marley 2022-02-16 03:41:50 UTC
Oh, I've also tried oc 4.8.23 and 4.9.9 with the same results.

Comment 3 John Marley 2022-02-16 04:18:55 UTC
I've also tried 4.8.3 (with the same results) which is the version in which this problem was supposedly fixed according to https://access.redhat.com/solutions/4952051

Comment 4 John Marley 2022-02-16 23:53:29 UTC
Found the solution.  When the mirror was copied to the internal network, the manifest symbolic links were not preserved.  With the links restored it's proceeding as expected.