Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1919032: Fix image extract from Root Directory #713

Conversation

zerodayz
Copy link
Contributor

This patch adds possibility to extract file from the root directory of an image.

Closes: BZ#1919032

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Jan 22, 2021
@openshift-ci-robot
Copy link

@zerodayz: This pull request references Bugzilla bug 1919032, which is invalid:

  • expected the bug to target the "4.7.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1919032: Fix image extract from Root Directory

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Jan 22, 2021
@zerodayz zerodayz force-pushed the FixImageExtract-From-RootDir branch 2 times, most recently from dc08ed8 to 32a29cb Compare January 22, 2021 07:10
@zerodayz
Copy link
Contributor Author

/test e2e-agnostic-cmd

@soltysh
Copy link
Member

soltysh commented Jan 22, 2021

/assign @sallyom

@soltysh
Copy link
Member

soltysh commented Jan 22, 2021

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 22, 2021
@openshift-ci-robot
Copy link

@soltysh: This pull request references Bugzilla bug 1919032, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@zerodayz
Copy link
Contributor Author

the problem is that when only file is being a source for example /help.1, the directory "parent" is "." and it was excluded because of the name == "." || parent == ".".

Even fixing this was not enough since tar doesn't consider /. meaning the root directory is omited, for example:
usr/lib/ instead of /usr/lib.

Hence adding new functions. I am unsure about the case/switch that can be further improved. Any feedback welcome @sallyom Let me know.

@sallyom
Copy link
Contributor

sallyom commented Jan 22, 2021

I see this PR fixes the bug, great!! Sharing to enable easy verifying:

$ touch hello
$ container=$(buildah from alpine)
$ buildah copy $container hello /hello
$ buildah commit --format docker $container localhost:5000/alpine:new
$ podman push localhost:5000/alpine:new
$ mkdir ext; cd ext
$ oc image extract localhost:5000/alpine:new --file /hello
$ ls
hello
$ rm hello && oc image extract localhost:5000/alpine:new --path /hello:/tmp/ext 
$ ls
hello

and for non root-dir extract:

$ touch hello-hello
$ container=$(buildah from alpine)
$ buildah copy $container hello /tmp/hello-hello
$ buildah commit --format docker $container localhost:5000/alpine:new-new
$ podman push localhost:5000/alpine:new-new
$ mkdir ext; cd ext
$ oc image extract localhost:5000/alpine:new --file /tmp/hello-hello
$ ls
hello-hello

@zerodayz
Copy link
Contributor Author

/retest

1 similar comment
@zerodayz
Copy link
Contributor Author

/retest

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
@sallyom owns the final tag

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 25, 2021
Copy link
Contributor

@sallyom sallyom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zerodayz I made a note in the file to fix the Alter fn. Also, you'll need to run
make update-gofmt (or gofmt -w -s pkg/cli/image/extract/extract.go) Then all looking good, thank you!

@zerodayz
Copy link
Contributor Author

/retest

@zerodayz zerodayz requested a review from sallyom January 27, 2021 07:31
@zerodayz
Copy link
Contributor Author

/retest

@zerodayz
Copy link
Contributor Author

/test e2e-agnostic-cmd

1 similar comment
@zerodayz
Copy link
Contributor Author

/test e2e-agnostic-cmd

@soltysh
Copy link
Member

soltysh commented Feb 1, 2021

This test should be fixed now
/test e2e-agnostic-cmd

@zerodayz
Copy link
Contributor Author

zerodayz commented Feb 1, 2021

/test e2e-agnostic-cmd

@zerodayz
Copy link
Contributor Author

zerodayz commented Feb 3, 2021

/cc @sallyom All tests are passing, would you be able to review again? Thanks!

@sallyom
Copy link
Contributor

sallyom commented Feb 8, 2021

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 8, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sallyom, soltysh, zerodayz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 42e9eb4 into openshift:master Feb 8, 2021
@openshift-ci-robot
Copy link

@zerodayz: All pull requests linked via external trackers have merged:

Bugzilla bug 1919032 has been moved to the MODIFIED state.

In response to this:

Bug 1919032: Fix image extract from Root Directory

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@smarterclayton
Copy link
Contributor

Changes like these need unit tests. I’d like to see a set added that verify the streamed function receives the correct files from a set of generated fake images before we allow more changes like this to these commands.

@soltysh
Copy link
Member

soltysh commented Feb 9, 2021

@zerodayz can you prepare tests ensuring this is working as designed in a followup?

@zerodayz
Copy link
Contributor Author

zerodayz commented Feb 9, 2021

@soltysh @smarterclayton Will work on unit tests today. My bad apologies.

@zerodayz
Copy link
Contributor Author

@soltysh @smarterclayton @sallyom I started putting together Unit tests for image extract in #736

It seems that there are no unit tests at all for image extract. So I am putting it together now, not just the extracting image, but parsing and other functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants