Skip to content

add podman artifact extract #25238

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

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Feb 5, 2025

Add a new command to extract the blob content of the artifact store to a local path.

Fixes https://issues.redhat.com/browse/RUN-2445

Does this PR introduce a user-facing change?

Added a new podman artifact extract command.

@openshift-ci openshift-ci bot added release-note do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 5, 2025
Copy link
Contributor

openshift-ci bot commented Feb 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 5, 2025
@Luap99
Copy link
Member Author

Luap99 commented Feb 5, 2025

Tests are still missing, will work on it tomorrow. Opening this to allow some early review.

cc @baude @Honny1 @mtrmac

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

must be used to select only a single blob. If the file already exists it will be
overwritten.

If the target is an directory (it must exist) all blobs will be copied to the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If the target is an directory (it must exist) all blobs will be copied to the
If the target is an directory (it must exist), all blobs will be copied to the

overwritten.

If the target is an directory (it must exist) all blobs will be copied to the
target directory. As target file name the value from `org.opencontainers.image.title`
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a typo here maybe ... did you mean "a" or "the" target file ?


If the target is an directory (it must exist) all blobs will be copied to the
target directory. As target file name the value from `org.opencontainers.image.title`
annotation is used. If the annotation is missing the target file name will be
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
annotation is used. If the annotation is missing the target file name will be
annotation is used. If the annotation is missing, the target file name will be

target directory. As target file name the value from `org.opencontainers.image.title`
annotation is used. If the annotation is missing the target file name will be
the digest of the blob (with `:` replaced by `-` in the name).
If the target file already exists in the directory it will be overwritten.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
If the target file already exists in the directory it will be overwritten.
If the target file already exists in the directory, it will be overwritten.

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

A fairly brief skim; ACK overall, some more design questions.

Note the ⚠️ .

title string
)
for _, l := range arty.Manifest.Layers {
if options.Digest == l.Digest.String() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Non-blocking: This probably can be structured as if layerMatchesOptions(…) { duplicate check; set digest/title }). This works fine as is, and it is short enough that it is not that necessary.

}
defer dest.Close()

// TODO use reflink is possible
Copy link
Member

Choose a reason for hiding this comment

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

is this a long term todo, or something you would do as part of this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is easy to do, but as usual I don't want to duplicate code and the c/image function is internal so I have to export it first then vendor again, etc... So not something I plan to do for this PR but I will be working on that soon enough.

@Luap99 Luap99 force-pushed the artifact-extract branch 2 times, most recently from 3bde1e7 to 73f058f Compare February 6, 2025 16:27
@Luap99
Copy link
Member Author

Luap99 commented Feb 6, 2025

I pushed 4 small artifacts for testing

quay.io/libpod/testartifact:20250206-single
quay.io/libpod/testartifact:20250206-multi
quay.io/libpod/testartifact:20250206-multi-no-title
quay.io/libpod/testartifact:20250206-evil

I leave the PR as draft for now and work to get them into our VM images to avoid flakes.

Copy link
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

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

I have only a few minor comments, mostly LGTM

Comment on lines +298 to +299
stat, err := os.Stat(target)
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
stat, err := os.Stat(target)
if err == nil {
if stat, err := os.Stat(target); err == nil {

Comment on lines +344 to +345
err = copyImageBlobToFile(ctx, imgSrc, l.Digest, filepath.Join(target, filename))
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err = copyImageBlobToFile(ctx, imgSrc, l.Digest, filepath.Join(target, filename))
if err != nil {
if err := copyImageBlobToFile(ctx, imgSrc, l.Digest, filepath.Join(target, filename)); err != nil {

Comment on lines +46 to +47
err := registry.ImageEngine().ArtifactExtract(registry.Context(), args[0], args[1], &extractOpts)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
err := registry.ImageEngine().ArtifactExtract(registry.Context(), args[0], args[1], &extractOpts)
if err != nil {
if err := registry.ImageEngine().ArtifactExtract(registry.Context(), args[0], args[1], &extractOpts); err != nil {

Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM

Luap99 added a commit to Luap99/automation_images that referenced this pull request Feb 10, 2025
This is needed by containers/podman#25238

To avoid flakes we need to have the test artifacts in the cache
registry.

Signed-off-by: Paul Holzinger <[email protected]>
Add a new command to extract the blob content of the artifact store to a
local path.

Fixes https://issues.redhat.com/browse/RUN-2445

Signed-off-by: Paul Holzinger <[email protected]>
@Luap99 Luap99 marked this pull request as ready for review February 11, 2025 14:18
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 11, 2025
@Luap99
Copy link
Member Author

Luap99 commented Feb 11, 2025

This is good to go, rebased on main with the image update to include the artifacts so we shoul dnot get any new pull flakes from it.
I work on the reflink change in another PR.

@baude
Copy link
Member

baude commented Feb 11, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 11, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 2f261d1 into containers:main Feb 11, 2025
83 checks passed
@Luap99 Luap99 deleted the artifact-extract branch February 11, 2025 18:57
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. lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants