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

Do not include a cache mount's ID in the ExecOp's cachemap #4585

Merged

Conversation

cpuguy83
Copy link
Member

A cache ID should not have any impact on whether or not a step should be re-run any more than the content of that cache does (or rather, doesn't).

@cpuguy83 cpuguy83 force-pushed the exclude_cachemount_id_from_cachemap branch from 4e7c61b to e2b73b6 Compare January 25, 2024 01:42
solver/llbsolver/ops/exec.go Outdated Show resolved Hide resolved
solver/llbsolver/ops/exec.go Outdated Show resolved Hide resolved
@cpuguy83 cpuguy83 force-pushed the exclude_cachemount_id_from_cachemap branch from e2b73b6 to 867839d Compare January 25, 2024 16:02
A cache ID should not have any impact on whether or not a step should be
re-run any more than the content of that cache does (or rather,
doesn't).

Signed-off-by: Brian Goff <[email protected]>
@cpuguy83 cpuguy83 force-pushed the exclude_cachemount_id_from_cachemap branch from 867839d to 584ec40 Compare January 25, 2024 16:53
Comment on lines +109 to +120
// This is a dockerfile default cache mount.
// We are treating this as a special case so we don't cause a cache miss unintentionally.
if m.CacheOpt.ID == m.Dest && m.CacheOpt.Sharing == 0 {
return false
}

// Check the case where a dockerfile cache-namespace may be used.
// This would be `<namespace>/<dest>`
_, trimmed, ok := strings.Cut(m.CacheOpt.ID, "/")
if ok && trimmed == m.Dest && m.CacheOpt.Sharing == 0 {
return false
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we condense these cases together? We can get the trimmed ID, and then compare and check the sharing, given they're essentially the same case.

I'm also still not sure I understand where this special case can actually happen. Is it just to prevent dockerfile cache misses when upgrading buildkit?

Copy link
Member Author

Choose a reason for hiding this comment

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

can we condense these cases together? We can get the trimmed ID, and then compare and check the sharing, given they're essentially the same case.

Seems like this would make the code more confusing, and certainly more expensive in the case where there is nothing to trim.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it just to prevent dockerfile cache misses when upgrading buildkit?

Yes, I believe so.
See the discussion thread here: https://dockercommunity.slack.com/archives/C7S7A40MP/p1705105919498119

@tonistiigi tonistiigi merged commit 4438f4f into moby:master Jan 26, 2024
62 checks passed
@cpuguy83 cpuguy83 deleted the exclude_cachemount_id_from_cachemap branch February 21, 2024 18:49
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.

3 participants