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 support for image expiration during garbage collection #9022

Merged
merged 3 commits into from Sep 12, 2023

Conversation

dmcgowan
Copy link
Member

@dmcgowan dmcgowan commented Aug 29, 2023

Update the garbage collector to support image expiration along with support for image leasing. This allows making images collectible during garbage collection and using a lease to prevent removal of an image.

The containerd.io/gc.ref.image label will also allow other other objects to reference an image directly, rather than just the content. This is useful to keep around image metadata and labels rather than just the image manifest.

Make it easier to see list differences in gc node test failure output.

Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan dmcgowan added this to the 2.0 milestone Aug 29, 2023
@fuweid
Copy link
Member

fuweid commented Aug 29, 2023

cc @cardyok

metadata/gc.go Outdated Show resolved Hide resolved
metadata/gc_test.go Outdated Show resolved Hide resolved
}

// If image doesn't have expiration, it does not need to be leased
if _, ok := labels[string(labelGCExpire)]; !ok {
Copy link
Member

Choose a reason for hiding this comment

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

Suggest to add integration test case for this. I think it will be a good example for developer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me look into adding a test under images for this, we don't usually unit test the non exported functions. I did find another fix for one of the tests though

@dmcgowan dmcgowan force-pushed the gc-image-collectible branch 2 times, most recently from 51a4b17 to 0949935 Compare August 30, 2023 23:45
Copy link
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

metadata/gc.go Outdated Show resolved Hide resolved
@henry118
Copy link
Member

One generic question: would the gc of an expired image consequently lead to GC of related resources like contents and snapshots?

Update the garbage collector to support image expiration along with
support for image leasing. This allows making images collectible during
garbage collection and using a lease to prevent removal of an image.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan
Copy link
Member Author

One generic question: would the gc of an expired image consequently lead to GC of related resources like contents and snapshots?

Yes, gc of an expired image is the equivalent of an image delete + gc

@estesp estesp merged commit 4f691fa into containerd:main Sep 12, 2023
44 checks passed
@dmcgowan dmcgowan changed the title gc: add support for image expiration Add support for image expiration during garbage collection Nov 1, 2023
@dmcgowan dmcgowan deleted the gc-image-collectible branch April 20, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants