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

Use filename in cache key to prevent collisions under rename #3203

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

Conversation

SJrX
Copy link

@SJrX SJrX commented Jun 16, 2024

Fixes #2241 #1678

Description

Issues #2241 #1678 both point to cases where renames can point to incorrect images being used with caching. This commit adds the path of the file (relative to the build context to the hash).

A different approach would be to change the underlying function in CacheHasher to include the name (and maybe file size), this was avoided for two reasons:

  1. It was unclear whether this would change or break the computed digests outside the context of caching.
  2. The CacheHasher does not know the prefix to strip in the filename to compute the hash.

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

Describe any changes here so maintainer can include it in the release notes, or delete this block.

Examples of user facing changes:
- kaniko adds a new flag `--registry-repo` to override registry

Issues GoogleContainerTools#2241 GoogleContainerTools#1678 both point to cases where renames can point to incorrect images being used with caching. This
commit adds the path of the file (relative to the build context to the hash).

A different approach would be to change the underlying function in CacheHasher to include the name (and maybe file size), this was avoided
for two reasons:

1. It was unclear whether this would change or break the computed digests outside the context of caching.
2. The CacheHasher does not know the prefix to strip in the filename to compute the hash.
@SJrX SJrX marked this pull request as ready for review June 16, 2024 20:02
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.

Caching ignores filenames when COPYing a directory of files
1 participant