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

Add --all to artifact rm #25355

Merged
merged 1 commit into from
Feb 20, 2025
Merged

Conversation

baude
Copy link
Member

@baude baude commented Feb 18, 2025

Add the ability to remove all artifacts with a --all|-a option in podman artifact rm.

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

Does this PR introduce a user-facing change?

Add ability to remove all artifacts in the local store

@openshift-ci openshift-ci bot added release-note approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 18, 2025
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

same as #25352 (review) about the fixes line

for _, art := range allArtifacts {
// Using the digest here instead of name to protect against
// an artifact that lacks a name
manifestDigest, err := art.GetDigest()
Copy link
Member

Choose a reason for hiding this comment

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

Should we ignore this and continue to catch TOCTOU?

Copy link
Member

Choose a reason for hiding this comment

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

Ignore errors I mean

Copy link
Member Author

Choose a reason for hiding this comment

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

i thought about this and using the multierror approach we have used elsewhere. I guess at this point it is about what you want ... so weigh in @mheon and @Luap99

Copy link
Member

Choose a reason for hiding this comment

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

We don't need a multi error IMO, but what we have to do is ignore the no such artifact error silently and just continue. Otherwise --all can produce an error if it races against other concurrent removals.

That said none of the artifact store is race free, one can easily corrupt the store right now. I am fine to keep this particular problem for another time. I don't think we have proper types error either that we could match.

}
}

if name != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Should we detect if options.All was also specified here and error?

Copy link
Member Author

Choose a reason for hiding this comment

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

my initial thought was ... we detect this on the client side already which covers local and remote-client use. So for the RESTFUL side, i would add to the tunnel side?

artifactRemoveReport, err := registry.ImageEngine().ArtifactRm(registry.Context(), args[0], entities.ArtifactRemoveOptions{})
var nameOrID string
if len(args) > 0 {
nameOrID = args[0]
Copy link
Member

Choose a reason for hiding this comment

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

What about multiple arguments being passed? Should we loop over args?

Copy link
Member Author

Choose a reason for hiding this comment

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

checkAllAndArgs() checks that prior

Copy link
Member

Choose a reason for hiding this comment

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

I don't see that check. It just verifies it's more than 0 - there's no check that it is exactly 1. As written, it seems arguments past 1 are discarded silently.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Luap99 made the same basic comment and I have it fixed locally

@baude baude force-pushed the artifactrmall branch 2 times, most recently from 3729f5c to 4684f7f Compare February 19, 2025 18:53
@baude baude force-pushed the artifactrmall branch 2 times, most recently from 6db00ad to 48b0b79 Compare February 20, 2025 14:40
Add the ability to remove all artifacts with a --all|-a option in podman
artifact rm.

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

Signed-off-by: Brent Baude <bbaude@redhat.com>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

/lgtm

var (
namesOrDigests []string
)
artifactDigests := make([]*digest.Digest, 0, len(namesOrDigests))
Copy link
Member

Choose a reason for hiding this comment

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

not blocking but this does not solve the pre allocate part because len(namesOrDigests) is 0 here. This must be moved directly above the artStore.Remove() loop.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2025
Copy link
Contributor

openshift-ci bot commented Feb 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude, 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-merge-bot openshift-merge-bot bot merged commit 1e7f810 into containers:main Feb 20, 2025
82 checks passed
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