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

[ci] wrong cache key for go modules #532

Open
diafour opened this issue Sep 19, 2023 · 0 comments
Open

[ci] wrong cache key for go modules #532

diafour opened this issue Sep 19, 2023 · 0 comments

Comments

@diafour
Copy link
Contributor

diafour commented Sep 19, 2023

Parallel jobs are trying to save cache using commit SHA as a key. This approach in not working. E.g. https://github.com/flant/shell-operator/pull/525/checks — all 3 jobs for this PR start downloading Go modules without cache.

Observed steps:

  1. Restore Go modules

    Cache not found for input keys: Linux-gomod-8e1baab1250f4cf5ce645ed41c9c4ff10cb431c494ef1f379617ca1bbb0ee8aa, Linux-gomod-

  2. Run go mod download

  3. Post restore Go modules

  4. 2 jobs can't save cache
    Failed to save: Unable to reserve cache with key Linux-gomod-8e1baab1250f4cf5ce645ed41c9c4ff10cb431c494ef1f379617ca1bbb0ee8aa, another job may be creating this cache. More details: Cache already exists. Scope: refs/pull/525/merge, Key: Linux-gomod-8e1baab1250f4cf5ce645ed41c9c4ff10cb431c494ef1f379617ca1bbb0ee8aa, Version: 2a8d0f2be1a88abb057cd9fcea9832bd16e7ab71798dbf93cd890eb9add83cf6

  5. Only one job saves the cache
    Cache Size: ~65 MB (67768951 B)
    Cache saved successfully
    Cache saved with key: Linux-gomod-8e1baab1250f4cf5ce645ed41c9c4ff10cb431c494ef1f379617ca1bbb0ee8aa

It is better to have predictable key to use cached modules. E.g., use keys linux-gomod-$BRANCH_NAME and linux-gomod-main. So jobs will always have cache from main branch.

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

No branches or pull requests

1 participant