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

Orb behaviour with restore_cache does not match what source code says it should be doing #123

Closed
jamesrwu opened this issue Feb 2, 2022 · 2 comments · Fixed by #137
Closed
Labels
bug Something isn't working

Comments

@jamesrwu
Copy link

jamesrwu commented Feb 2, 2022

Orb version: 5.0.0

What happened:

In our node/install-packages step, I notice the restore_cache output to be something like this:

No cache is found for key: node-deps-arch1-linux-amd64-6_85-v1-WEBPLAT-1424-otawg9WNM0SS_vutk39ZUPxQPgxUCFt5g4TXo9whdYs=
Found a cache from build 188495 at node-deps-arch1-linux-amd64-6_85-v1-WEBPLAT-1424-3zVE04aLnLzo5ttkKIxeRB9NIhoXVIiqLiwkGMKBONA=

After which npm ci runs for 5 minutes or so. After that is done, I notice that it is skipping cache generation with such a message

Skipping cache generation, cache already exists for key: node-deps-arch1-linux-amd64-6_85-v1-WEBPLAT-1424-3zVE04aLnLzo5ttkKIxeRB9NIhoXVIiqLiwkGMKBONA=-otawg9WNM0SS_vutk39ZUPxQPgxUCFt5g4TXo9whdYs=

Expected behavior:

Based on the source code as I see here:

- restore_cache: # Include branch and package.json checksum if defined. Prioritize lock-file as it is a more definitive version of dependency cache.
keys:
- node-deps-{{ arch }}-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>><<^parameters.cache-only-lockfile>>{{ checksum "/tmp/node-project-package.json" }}-<</parameters.cache-only-lockfile>>{{ checksum "/tmp/node-project-lockfile" }}
- node-deps-{{ arch }}-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>>{{ checksum "/tmp/node-project-package.json" }}
- node-deps-{{ arch }}-<<parameters.cache-version>>-<<#parameters.include-branch-in-cache-key>>{{ .Branch }}-<</parameters.include-branch-in-cache-key>>
My expectation
is that during the cache restore step, it would have searched for the same cache key that eventually got generated npm ci step.

Additional Information:

Additional context from our config.yaml:

  node: circleci/[email protected]

We're running node/install-packages with no custom parameters.

@jamesrwu jamesrwu added the bug Something isn't working label Feb 2, 2022
@jamesrwu jamesrwu changed the title Orb behaviour does not match what source code says it should be doing Orb behaviour with restore_cache does not match what source code says it should be doing Feb 2, 2022
@Jaryt
Copy link
Contributor

Jaryt commented Feb 7, 2022

Hi James!

Thanks for bringing this up. Can you increment the cache-version parameter to "v2" and see if this behavior persists?

@nicklozon nicklozon mentioned this issue Mar 3, 2022
6 tasks
@nicklozon
Copy link
Contributor

Ran into this too - the cache key when saving is not respecting the cache-only-lockfile parameter when set to true which is the default.

#129 attempts to solve the issue

Workaround: Set cache-only-lockfile: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants