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
Better GitHub CI caching strategy for golang #9495
Conversation
2111848
to
d59f102
Compare
@@ -0,0 +1,27 @@ | |||
name: 'Setup golang with master only caching' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably stupid question: what is the benefit of doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at our Actions caches https://github.com/k3s-io/k3s/actions/caches, we keep going over our 10GB limit with a bunch of setup-go-Linux-ubuntu22-go-1.21.7-bda3a8cce4ad2d34dfb706b901c4ce11eab6d77c2d08dd8f0eae8694a7a27733
caches. Alot of these are from PRs, whose caches are ONLY valid for the PR that opened them for security reasons (cache poisoning prevention).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is to only allow master
branch to Save a valid cache entry, because that cache is usable by all PRs, as along as the checksum is the same (ie no changes to go.mod).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Derek
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now, thanks for the explanation. I have one last question: how long is a cache saved? I'm worried about the case where I open a PR to master but I don't merge because we are on code freeze and then after some days, I create the backports. Could it be that the cache does not exist anymore? In that case, what would happen? It seems we fall back to the restore-key
cache which could be built with other go version or go.sum, right? Thanks in advance for this clarification!
@@ -0,0 +1,27 @@ | |||
name: 'Setup golang with master only caching' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Derek
Caches that are access at least once a week are saved forever. This assumes you stay under the 10GB limit of course. See Eviction policy. With this change, we will not be caching |
Thanks again for the explanation. As it restores the cache when |
Signed-off-by: Derek Nola <derek.nola@suse.com>
e36e7e5
to
5bd34b0
Compare
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Signed-off-by: Derek Nola <derek.nola@suse.com>
Proposed Changes
Builds off of #9479 (will be rebased when that merges)
Use a custom caching strategy for GitHub Action
setup-go
, which restricts:Types of Changes
GitHub CI
Verification
For now, this PR should not open any new caches
Linked Issues
#9494
User-Facing Change
Further Comments