actions / cache

Cache dependencies and build outputs in GitHub Actions
MIT License
4.51k stars 1.2k forks source link

Unexpected cache misses since Feb 17th #1114

Closed chetbox closed 1 year ago

chetbox commented 1 year ago

I am getting unexpected cache misses using actions/cache@v3 since yesterday on a scheduled job that runs every 2 hours.

    - uses: actions/cache@v3
      with:
        path: folder
        key: folder-${{ env.SUFFIX }}
        restore-keys: |
          folder-
        fail-on-cache-miss: true

I am using the option fail-on-cache-miss: true, because restoring the cache is critical to the job running, so the action fails with the error:

Error: Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: folder-73489456

I have not deleted cache entries and I have verified that prefix-matched cache entries exist with:

gh api \
  -H "Accept: application/vnd.github+json" \
  /repos/OWNER/REPO/actions/caches

Further details here: https://github.com/actions/runner/issues/2448 (I wasn't sure where to create this issue as I don't fully understand where the error is, sorry! I'm reporting here as suggested by this comment. If there is a more appropriate place to report this issue please let me know.)

michaelwilner commented 1 year ago

Bump. Seeing this consistently today as well, even with enableCrossOsArchive: true and restore keys also missing

rfay commented 1 year ago

Me too, especially Windows caches being restored on linux. (Again).

rfay commented 1 year ago

I'm seeing this failure when Windows cache is being created... but not detected by the Windows cache creation; it should be a fail. Full run in https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056

Cache creation failure, not detected as failure ``` ##[debug]Evaluating condition for step: 'Cache signed binaries' ##[debug]Evaluating: success() ##[debug]Evaluating success: ##[debug]=> *** ##[debug]Result: *** ##[debug]Starting: Cache signed binaries ##[debug]Register post job cleanup for action: actions/cache@v3 ##[debug]Loading inputs ##[debug]Evaluating: format('{0}-{1}-signed-windows-binaries', github.sha, github.ref) ##[debug]Evaluating format: ##[debug]..Evaluating String: ##[debug]..=> '{0}-{1}-signed-windows-binaries' ##[debug]..Evaluating Index: ##[debug]....Evaluating github: ##[debug]....=> Object ##[debug]....Evaluating String: ##[debug]....=> 'sha' ##[debug]..=> 'dc674f463[2](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:2)9e64f00547c9c17e8190b178c[3](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:3)e927' ##[debug]..Evaluating Index: ##[debug]....Evaluating github: ##[debug]....=> Object ##[debug]....Evaluating String: ##[debug]....=> 'ref' ##[debug]..=> 'refs/heads/master' ##[debug]=> 'dc67[4](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:4)f46329e64f00[5](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:5)47c9c17e8190b178c3e927-refs/heads/master-signed-windows-binaries' ##[debug]Result: 'dc[6](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:6)[7](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:7)4f46329e64f00547c9c17e[8](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:8)1[9](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:9)0b178c3e927-refs/heads/master-signed-windows-binaries' ##[debug]Loading env Run actions/cache@v3 with: path: .gotmp/bin/windows_amd64 key: dc674f46329e64f00547c9c17e8190b178c3e927-refs/heads/master-signed-windows-binaries enableCrossOsArchive: false fail-on-cache-miss: false env: BUILDKIT_PROGRESS: plain DOCKER_CLI_EXPERIMENTAL: enabled DDEV_DEBUG: *** GITHUB_REPOSITORY_OWNER: DDEV_WINDOWS_SIGN: *** HOMEBREW_GITHUB_API_TOKEN: *** SegmentKey: *** ##[debug]Resolved Keys: ##[debug]["dc674f46329e64f00547c9c17e8190b178c3e927-refs/heads/master-signed-windows-binaries"] ##[debug]Checking zstd --version ##[debug]*** zstd command line interface 64-bits v1.5.2, by Yann Collet *** ##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/zawRn5dEKBslveKq0hKqeGgT9pzbUVWMS67TS6TNuQdJulCkiw/_apis/artifactcache/cache?keys=dc674f46329e64f00547c9c17e8190b178c3e927-refs%2Fheads%2Fmaster-signed-windows-binaries&version=f55fc8623a0eb1f1ea00ce80[13](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:13)5058e0[17](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:17)f8832472807458ae532fb4e13c8bd7 ##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/zawRn5dEKBslveKq0hKqeGgT9pzbUVWMS67TS6TNuQdJulCkiw/_apis/artifactcache/caches?key=dc674f46329e64f00547c9c17e8[19](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:19)0b178c3e9[27](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:27)-refs%2Fheads%2Fmaster-signed-windows-binaries ##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink '' Cache not found for input keys: dc674f463[29](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:29)e64f00547c9c17e8190b178c3e927-refs/heads/master-signed-windows-binaries ##[debug]Node Action run completed with exit code 0 ##[debug]Save intra-action state CACHE_KEY = dc674f46[32](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:32)9e64f005[47](https://github.com/drud/ddev/actions/runs/4212708513/jobs/7311920056#step:7:48)c9c17e8190b178c3e927-refs/heads/master-signed-windows-binaries ##[debug]Finishing: Cache signed binaries ```
MikeSchulze commented 1 year ago

Hi i run also into this issue

Run actions/cache@v3.2.5
  with:
    path: ~/godot-linux
    key: Linux-Godot_v4.0-rc2
    enableCrossOsArchive: false
    fail-on-cache-miss: false
Cache not found for input keys: Linux-Godot_v4.0-rc2

my action

    - name: "Cache Godot Binary Download"
      uses: actions/cache@v3.2.5
      id: godot-cache-binary
      with:
        path: ${{ inputs.godot-cache-path }}
        key: ${{ runner.OS }}-Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}
        restore-keys: |
          ${{ runner.OS }}-Godot_v${{ inputs.godot-version }}-${{ inputs.godot-status-version }}

    - name: "Install Linux Godot ${{ inputs.godot-version }}"
      if: steps.godot-cache-binary.outputs.cache-hit != 'true'

But the cache exist image

cdce8p commented 1 year ago

Probably a duplicate of #1110 Likely caused by the zstd update on the runner images.

ArtemGoutsoul commented 1 year ago

Got the same issue after Feb 17.

rohanKanojia commented 1 year ago

Hi guys, I'm facing the same issue. Were you able to find some workaround for this? I tried reverting actions/cache to previous version but it doesn't seem to fix the issue.

lvpx commented 1 year ago

Hi @rohanKanojia we have released a new version that fixes this. Please try again and see if it works for you.

rohanKanojia commented 1 year ago

@pdotl : The issue seems to be resolved by upgrade. Thanks a lot!

rfay commented 1 year ago

Those of us with self hosted windows runners have to upgrade zstd? What version is required?

lvpx commented 1 year ago

@rfay I don't think that should be necessary. I tested with v1.4.4 of zstd in a self-hosted runner and it worked as expected.

rfay commented 1 year ago

I'm not getting cache restores successfully yet, using actions/cache@v3

https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692

Cache is created on self-hosted Windows (zstd v1.5.2) and wants to be restored on Github-hosted Ubuntu 22.04 (zstd v1.5.4).

Restore attempt (linux) gets this sequence:

##[debug]Resolved Keys:
##[debug]["86536ded9253a798ec4f563fc28f5c76059a3657-refs/heads/master-signed-windows-binaries"]
##[debug]Checking zstd --quiet --version
##[debug]1.5.4
##[debug]zstd version: 1.5.4
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/zawRn5dEKBslveKq0hKqeGgT9pzbUVWMS67TS6TNuQdJulCkiw/_apis/artifactcache/cache?keys=86536ded9253a798ec4f563fc28f5c76059a3657-refs%2Fheads%2Fmaster-signed-windows-binaries&version=3d66d53693975ac4727514063416ac87965b1ce91f1c7b3a404342f[44](https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692#step:6:45)3747b09
##[debug]Resource Url: https://artifactcache.actions.githubusercontent.com/zawRn5dEKBslveKq0hKqeGgT9pzbUVWMS67TS6TNuQdJulCkiw/_apis/artifactcache/caches?key=86536ded9253a798ec4f563fc28f5c76059a3657-refs%2Fheads%2Fmaster-signed-windows-binaries
##[debug]No matching cache found for cache key '86536ded9253a798ec4f563fc28f5c76059a3657-refs/heads/master-signed-windows-binaries', version '3d66d53693975ac4727514063416ac87965b1ce91f1c7b3a404342f443747b09 and scope refs/heads/master. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key 
##[debug]Other caches with similar key:
##[debug]Cache Key: 86536ded9253a798ec4f563fc28f5c76059a3657-refs/heads/master-signed-windows-binaries, Cache Version: f55fc8623a0eb1f1ea00ce80135058e017f8832472807[45](https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692#step:6:46)8ae[53](https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692#step:6:54)2fb4e13c8bd7, Cache Scope: refs/heads/master, Cache Created: 2023-02-19T16:21:31.5966667Z
##[debug]Failed to delete archive: Error: ENOENT: no such file or directory, unlink ''
Cache not found for input keys: 86536ded9253a798ec4f563fc28f5c76059a3657-refs/heads/master-signed-windows-binaries
##[debug]Node Action run completed with exit code 0
##[debug]Save intra-action state CACHE_KEY = 86536ded9253a798ec4f[56](https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692#step:6:57)3fc28f5c76059a36[57](https://github.com/drud/ddev/actions/runs/4217111015/jobs/7363125692#step:6:58)-refs/heads/master-signed-windows-binaries
##[debug]Finishing: Restore Signed Windows artifacts
rfay commented 1 year ago

As this process has for a really long time, the windows instance has had gnu tar and zstd. I upgraded zstd based on chatter in this issue.

If you are using a self-hosted Windows runner, GNU tar and zstd are required for Cross-OS caching to work. They are also recommended to be installed in general so the performance is on par with hosted Windows runners.

I also switched from actions/cache@v3.0.11 (pinned because of previous https://github.com/actions/cache/issues/891) to actions/cache@v3.

But I don't seem to be having any success at all.

rfay commented 1 year ago

My problem was that I had not yet handled the requirements in cross-os caching

I needed enableCrossOsArchive: true:

      - name: Restore Signed Windows artifacts
        uses: actions/cache@v3
        id: signedwindows
        with:
          path: .gotmp/bin/windows_amd64
          key: ${{ github.sha }}-${{ github.ref }}-signed-windows-binaries
          enableCrossOsArchive: true
          fail-on-cache-miss: true