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 image prune --filter support #3319

Merged

Conversation

austinvazquez
Copy link
Member

@austinvazquez austinvazquez commented Aug 17, 2024

Description

This change adds nerdctl image prune --filter support including:

  • image prune --filter label=<key>=<value>
  • image prune --filter until=<timestamp>

Testing

  • Added unit tests for pkg/imgutil code
  • Added integration tests for cmd/nerdctl/image_prune code
    • TestImagePruneFilterUntil does not currently work on Docker. Docker image's created timestamp is aligning with the timestamp of the base image. Docker supports the until filter; just didn't have any ideas for deterministically testing both behaviors.

References

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
@austinvazquez austinvazquez marked this pull request as ready for review August 17, 2024 06:19
@austinvazquez austinvazquez force-pushed the feat-add-image-prune-filter branch 2 times, most recently from d1935e7 to 360423f Compare August 17, 2024 15:02
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Aug 17, 2024
base.Cmd("images", "--all").AssertOutContains(imageName)

// Pause to ensure enough time has passed for the image to be clean on next prune.
time.Sleep(1 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

This might be too short?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried increase the pause to 3 seconds and lowering the requirement to 10ms to provide two orders of magnitude here. Should be pretty reliable. 😅

},
{
name: "SingleMatchingLabel",
imageLabels: map[string]string{"org": "com.containerd.nerdctl"},
Copy link
Member

Choose a reason for hiding this comment

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

Better to use com.example...

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 7dd3050 into containerd:main Aug 17, 2024
20 checks passed
@austinvazquez austinvazquez deleted the feat-add-image-prune-filter branch August 17, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants