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

fix: sourceImage's CreatedAt timestamp should not be included in cache key #3338

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mzihlmann
Copy link

@mzihlmann mzihlmann commented Oct 10, 2024

#3088 (comment)

doesn't fix #3088 but is related to that issue

Description

Currently the CreatedAt timestamp (and all other metadata) is included into kaniko's cache key, this means that if a new image is created with the exact same layers, it invalidates caches in all builds that use it as a base.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

Release Notes

  • kaniko cache learned to ignore CreatedAt field in base images

Copy link

google-cla bot commented Oct 10, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mzihlmann mzihlmann changed the title fix: sourceImage's CreatedAt timestamp should not be included in cach… fix: sourceImage's CreatedAt timestamp should not be included in cache key Oct 10, 2024
@mzihlmann
Copy link
Author

labels can be excluded as well with this diff, which would indeed fix #3088

+ cf, err := sourceImage.ConfigFile()
+ if err != nil {
+ 	return nil, err
+ }
+ cfg := cf.DeepCopy()
+ cfg.Created = v1.Time{}
+ cfg.Config.Labels = map[string]string{}
+ sourceImageReproducible, err := mutate.ConfigFile(sourceImage, cfg)
+ if err != nil {
+ 	return nil, err
+ }
+ 
+ digest, err := sourceImageReproducible.Digest()
- digest, err := sourceImage.Digest()

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.

--label causes cache invalidation in later stages
1 participant