Bug 1904006 - The --dir option doest not work for command `oc image extract`
Summary: The --dir option doest not work for command `oc image extract`
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.7
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ---
: 4.8.0
Assignee: Sally
QA Contact: RamaKasturi
URL:
Whiteboard:
: 1906277 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-12-03 11:13 UTC by zhou ying
Modified: 2021-07-27 22:35 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-07-27 22:34:40 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift oc pull 729 0 None closed Bug 1904006: update and clarify --dir --from-dir flags with 'oc image' 2021-02-15 05:34:25 UTC
Red Hat Product Errata RHSA-2021:2438 0 None None None 2021-07-27 22:35:11 UTC

Description zhou ying 2020-12-03 11:13:39 UTC
Description of problem:

Can't specify the dir by `oc image extract --dir`

Version-Release number of selected component (if applicable):
Client Version: 4.7.0-202011302220.p0-6775115
Kubernetes Version: v1.11.0+d4cacc0

How reproducible:
Always

Steps to Reproduce:
1. Current dir is :/home/test
2, Run command `oc image extract --dir=/home/test/1203 registry.redhat.io/openshift4/ose-must-gather:latest --filter-by-os='linux/amd64' -p`

Actual results:
2. Will try to extract to current dir, not the --dir specify.
error: directory /home/test must be empty, pass --confirm to overwrite contents of directory
Expected results:
1. Can specify the directory on disk, and extract to --dir .


Additional info:

Comment 3 Michal Fojtik 2021-01-03 15:58:22 UTC
This bug hasn't had any activity in the last 30 days. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're marking this bug as "LifecycleStale" and decreasing the severity/priority. If you have further information on the current state of the bug, please update it, otherwise this bug can be closed in about 7 days. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. Additionally, you can add LifecycleFrozen into Keywords if you think this bug should never be marked as stale. Please consult with bug assignee before you do that.

Comment 4 zhou ying 2021-01-04 02:04:15 UTC
The issue still exist.

Comment 5 Sally 2021-01-04 20:39:04 UTC
I'll be looking to resolve this in the upcoming sprint.

Comment 6 Sally 2021-02-05 05:38:36 UTC
From the PR review, (https://github.com/openshift/oc/pull/685) I believe this is another case of confusing flags and better documentation needed. The 'extract' command is always meant to extract to the current directory. The flag description for 
--dir is confusing at best. 

'--dir='': The directory on disk that file:// images will be copied under' should be improved. With extract, it's easy to assume --dir would be the directory one would like to extract into. I'll be improving the help for this command, working on it this sprint.

Comment 7 Sally 2021-02-05 19:55:38 UTC
I've determined the '--dir' and '--from-dir' flags are the source of much confusion and in some cases (such as this, with extract) aren't wired properly. I've pushed a change that will be up for review in https://github.com/openshift/oc/pull/729:

oc image extract:
 - remove --dir flag, might add flag to allow to extract into other directory other than current (in a followup PR)

oc image info:
 - the --dir flag should be updated to be `--from-dir` to allow to read from a directory on disk (other than `v2` in current directory) 

oc image append: 
 - remove the --dir flag
 - keep the `--from-dir` flag to allow to read from a directory on disk (other than `v2` in current directory)
 - Add the `--to-dir` flag to replace the `--dir`

Comment 8 Sally 2021-02-10 21:34:30 UTC
*** Bug 1906277 has been marked as a duplicate of this bug. ***

Comment 10 RamaKasturi 2021-02-12 18:05:53 UTC
No nightly has been accepted for last 2 days, will check this on monday.

Comment 11 RamaKasturi 2021-02-15 16:20:34 UTC
According to the PR i see that the help has been modified, will move the bug to verified state once a nightly build has been accepted.

Comment 12 RamaKasturi 2021-02-22 13:47:29 UTC
Verified with the build below and i see that oc image extract help has been updated. Based on that moving bug to verified state.

[knarra@knarra openshift-client-linux-4.8.0-0.nightly-2021-02-21-102854]$ ./oc version -o yaml
clientVersion:
  buildDate: "2021-02-20T04:51:51Z"
  compiler: gc
  gitCommit: 13f3e4b73df9b0853979e4130adf756784afe96f
  gitTreeState: clean
  gitVersion: 4.8.0-202102200123.p0-13f3e4b
  goVersion: go1.15.5
  major: ""
  minor: ""
  platform: linux/amd64
openshiftVersion: 4.8.0-0.nightly-2021-02-21-102854
releaseClientVersion: 4.8.0-0.nightly-2021-02-21-102854
serverVersion:
  buildDate: "2021-02-19T22:50:50Z"
  compiler: gc
  gitCommit: 01ab7fd5278756572d4a1dd3101f0a6d5c969824
  gitTreeState: clean
  gitVersion: v1.20.0+01ab7fd
  goVersion: go1.15.5
  major: "1"
  minor: "20"
  platform: linux/amd64


Unless the --path flag is passed, image contents will be extracted into the current directory.
		Pass images to extract as arguments. The --path flag allows you to define multipl

Examples:
  # Extract the busybox image into the current directory
  oc image extract docker.io/library/busybox:latest
  
  # Extract the busybox image into a designated directory (must exist)
  oc image extract docker.io/library/busybox:latest --path /:/tmp/busybox
  
  # Extract the busybox image into the current directory for linux/s390x platform
  # Note: Wildcard filter is not supported with extract. Pass a single os/arch to extract.
  oc image extract docker.io/library/busybox:latest --filter-by-os=linux/s390x
  
  # Extract a single file from the image into the current directory
  oc image extract docker.io/library/centos:7 --path /bin/bash:.
  
  # Extract all .repo files from the image's /etc/yum.repos.d/ folder into the current directory
  oc image extract docker.io/library/centos:7 --path /etc/yum.repos.d/*.repo:.
  
  # Extract all .repo files from the image's /etc/yum.repos.d/ folder into a designated directory (must exist)
  # this results in /tmp/yum.repos.d/*.repo on local system
  oc image extract docker.io/library/centos:7 --path /etc/yum.repos.d/*.repo:/tmp/yum.repos.d
  
  # Extract an image stored on disk into the current directory ($(pwd)/v2/busybox/blobs,manifests exists)
  # --confirm is required because current directory is not empty
  oc image extract file://busybox:local --confirm
  
  # Extract an image stored on disk in a directory other than $(pwd)/v2 into the current directory
  # --confirm is required because current directory is not empty ($(pwd)/busybox-mirror-dir/v2/busybox exists)
  oc image extract file://busybox:local --dir busybox-mirror-dir --confirm
  
  # Extract an image stored on disk in a directory other than $(pwd)/v2 into a designated directory (must exist)
  oc image extract file://busybox:local --dir busybox-mirror-dir --path /:/tmp/busybox
  
  # Extract the last layer in the image
  oc image extract docker.io/library/centos:7[-1]
  
  # Extract the first three layers of the image
  oc image extract docker.io/library/centos:7[:3]
  
  # Extract the last three layers of the image
  oc image extract docker.io/library/centos:7[-3:]

Comment 15 errata-xmlrpc 2021-07-27 22:34:40 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.8.2 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:2438


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