buildkit icon indicating copy to clipboard operation
buildkit copied to clipboard

S3 cache: support expired objects

Open aviau opened this issue 3 years ago • 3 comments

Hello!

Now that buildkit support S3 caching, it would be great if there was a supported way for bucket administrators to expire objects in the bucket without breaking subsequent builds.

Currently, if I delete blobs and have manifests that still point to them, I get the following error:

ERROR: failed to solve: operation error S3: GetObject, https response error StatusCode: 404

Could this be handled gracefully instead? For example by just resuming the build without that cached blob.

In an ideal world, we are able to set a lifecycle policy to our s3 buckets that will expire objects in the cache after a number of days.

My current workaround for this is to use the current month as the S3 prefix and expire objects after 60 days. This ensures that all objects in the currently used cache are never expired, and the one from the previous month get deleted.

aviau avatar Oct 26 '22 02:10 aviau

Is there another way to work with s3 cache cleanup ?

hinupurthakur avatar Aug 18 '25 06:08 hinupurthakur

My current workaround for this is to use the current month as the S3 prefix and expire objects after 60 days. This ensures that all objects in the currently used cache are never expired, and the one from the previous month get deleted.

@aviau Also, how does this work? Does it surge cache on the day 1 of each month ? or do you use different prefix for cache-to and cache-from

hinupurthakur avatar Aug 18 '25 06:08 hinupurthakur

On day 1 of the months its as if we are starting clean with no cache. Very quickly the cache builds up and the cache from the previous month is now completely unused and ends up being deleted by the lifecycle policy.

aviau avatar Aug 19 '25 11:08 aviau