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

Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read #238

Closed
zoey-juan opened this issue May 31, 2024 · 6 comments

Comments

@zoey-juan
Copy link

Hi,
We have checked several discussion and reported issues but still we're getting a bunch of warnings after updating to gradle/actions/setup-gradle@v3. I'm wondering if any suggestions how to fix those issues properly.

Setup

Added the gradle workaround.

    - name: Set /usr/bin/gradle alias to gradlew # workaround: https://github.com/gradle/actions/issues/33
      shell: bash
      run: sudo ln -s "$GITHUB_WORKSPACE/gradlew" /usr/bin/gradle
    - uses: gradle/actions/setup-gradle@v3
      with:
        gradle-version: wrapper
        # Excludes ~/.gradle/caches/build-cache-1/ already provided by GE remote caching
        gradle-home-cache-excludes: caches/build-cache-gu
        gradle-home-cache-cleanup: true
        cache-read-only: false // for testing on non-master branch only

Disable local cache regarding to the readme doc

buildCache {
    local {
        isEnabled = System.getenv("CI") == null
        directory = File(gradle.gradleUserHomeDir, "build-cache-gu")
        removeUnusedEntriesAfterDays = 15
    }
    remote<HttpBuildCache> {
        isEnabled = System.getenv("CI") != null
        isPush = System.getenv("CI") != null
        setUrl("$gradleEnterpriseUrl/cache/")
    }
}

Warnings

Screenshot 2024-05-31 at 20 16 03
build_debug / android-build
Unhandled error in Gradle post-action - job will continue: Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
build_debug / android-build
Failed to save cache entry with path '/home/runner/.gradle/caches/transforms-4/*/ /home/runner/.gradle/caches/*/transforms/*/' and key: gradle-transforms-v1-feb3ccfac262ee449fb58b558de5457a: Error: Cache service responded with 429 during upload chunk.

 

@bigdaz
Copy link
Member

bigdaz commented Jun 4, 2024

Are you running GitHub Enterprise? This looks like the sort of error that would be caused by network infrastructure blocking certain requests (or requests over a certain size).

You could test a workflow using actions/cache. The setup-gradle action relies on the actions/cache library under the covers. If a similar workflow fails with actions/cache then it would clearly indicate something that cannot be fixed in setup-gradle.

@bigdaz
Copy link
Member

bigdaz commented Jun 4, 2024

See this issue that was due to GHES installation: #235

@zoey-juan
Copy link
Author

bigdaz Thank you! I have contacted our infrastructure team and am awaiting their response.
In the meantime, I am attaching the error details here to see if they can help identify the issue.

Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
      at ReadStream.<anonymous> (/runner/_work/_actions/gradle/actions/v3/dist/setup-gradle/post/index.js:6942:31)
      at ReadStream.emit (node:events:519:28)
      at emitErrorNT (node:internal/streams/destroy:169:8)
      at errorOrDestroy (node:internal/streams/destroy:[23](https://github.com/*/actions/runs/9514183405/job/26225834331#step:10:23)8:7)
      at node:internal/fs/streams:272:9
      at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)

@bigdaz
Copy link
Member

bigdaz commented Jun 14, 2024

Is this error coming from GitHub Enterprise, or from github.com?

@zoey-juan
Copy link
Author

Hi @bigdaz,

The issues I'm facing is exactly the same as this issue report comment

  • By using the actions/cache@v4, the 2 scenarios is as follows:
  1. this is showing as warning in the github annotations of summary.
Post job cleanup.
Post job cleanup.
/bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /runner/_work/xxx-android/xxx --files-from manifest.txt --use-compress-program zstdmt
Warning: Failed to save: Cache service responded with [429](https://github.com/{organization}/xxx-android/actions/runs/9542615689/job/26297726416#step:19:2) during upload chunk.
Warning: Cache upload failed because file read failed with EBADF: bad file descriptor, read
Warning: Cache upload failed because file read failed with EBADF: bad file descriptor, read
Warning: Cache upload failed because file read failed with EBADF: bad file descriptor, read
Cache saved with key: Linux-gradle-5d785a1be5dd7676e2e6e066[3](https://github.com/{organization}/xxx-android/actions/runs/9542615689/job/26297726416#step:19:3)35b13e2b1e2a5b780f81bbd7d3a267f21420af4
  1. this is Not showing as warning in the github annotations of summary.
Failed to save: Unable to reserve cache with key Linux-gradle-a54f3966756dcb86b9b84b474810a1233fbf777a12342d2218bf1dcd0fb6b1fe, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/test/upgrade-ge-plugin-0613, Key: Linux-gradle-a54f3966756dcb86b9b84b474810a1233fbf777a12342d2218bf1dcd0fb6b1fe, Version: 569019faed09f5f63af8a1ab2f5e0433d94f66e572509c03e0e3df35d24400c7
  • By using actions/setup-gradle@v3
Post job cleanup.
Post job cleanup.
In post-action stepxxx
Stopping all Gradle daemons before saving Gradle User Home state
Stopping Gradle daemons for /home/runner/.gradle/wrapper/dists/gradle-8.8-bin/dl7vupf4psengwqhwktix4v1/gradle-8.8
/home/runner/.gradle/wrapper/dists/gradle-8.8-bin/dl7vupf4psengwqhwktix4v1/gradle-8.8/bin/gradle --stop
No Gradle daemons are running.
Caching Gradle state
  Caching dependencies with path '/home/runner/.gradle/cac{organization}hes/modules-*/files-*/*/*/*/*' and cache key: gradle-dependencies-v1-505efcf49b7d35b0bd31492bfd24c583
  Caching kotlin-dsl with path '/home/runner/.gradle/caches/*/kotlin-dsl/accessors/*/
  /home/runner/.gradle/caches/*/kotlin-dsl/scripts/*/' and cache key: gradle-kotlin-dsl-v1-da6caf1206193a60891708595757e6c9
  /bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /runner/_work/xxx-groundup-android/xxx-groundup-android --files-from manifest.txt --use-compress-program zstdmt
  /bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /runner/_work/xxx-groundup-android/xxx-groundup-android --files-from manifest.txt --use-compress-program zstdmt
  Failed to save cache entry with path '/home/runner/.gradle/caches/*/kotlin-dsl/accessors/*/
  /home/runner/.gradle/caches/*/kotlin-dsl/scripts/*/' and key: gradle-kotlin-dsl-v1-da6caf1206193a60891708595757e6c9: ReserveCacheError: Unable to reserve cache with key gradle-kotlin-dsl-v1-da6caf1206193a60891708595757e6c9, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/test/upgrade-ge-plugin-0613, Key: gradle-kotlin-dsl-v1-da6caf1206193a60891708595757e6c9, Version: 8545d9e724bff3a04034d94571382fd72c41d439d40c29827655b1b859c8de72
  Failed to save cache entry with path '/home/runner/.gradle/caches/modules-*/files-*/*/*/*/*' and key: gradle-dependencies-v1-505efcf49b7d35b0bd31492bfd24c583: ReserveCacheError: Unable to reserve cache with key gradle-dependencies-v1-505efcf49b7d35b0bd31492bfd24c583, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/test/upgrade-ge-plugin-0613, Key: gradle-dependencies-v1-505efcf49b7d35b0bd31492bfd24c583, Version: 1c52a3a7b4256dbf4cb0b91ebdf0637b7fca6c8cf427ab687855671174f38301

  Caching transforms with path '/home/runner/.gradle/caches/transforms-4/*/
  /home/runner/.gradle/caches/*/transforms/*/' and cache key: gradle-transforms-v1-baba20cb81b879353fe47a4fd1b135c0
  /bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /runner/_work/xxx-groundup-android/xxx-groundup-android --files-from manifest.txt --use-compress-program zstdmt
  Warning: Unhandled error in Gradle post-action - job will continue: Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
  Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
      at ReadStream.<anonymous> (/runner/_work/_actions/gradle/actions/v3/dist/setup-gradle/post/index.js:6942:31)
      at ReadStream.emit (node:events:519:28)
      at emitErrorNT (node:internal/streams/destroy:169:8)
      at errorOrDestroy (node:internal/streams/destroy:238:7)
      at node:internal/fs/streams:272:9
      at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)
  Warning: Unhandled error in Gradle post-action - job will continue: Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
  Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
      at ReadStream.<anonymous> (/runner/_work/_actions/gradle/actions/v3/dist/setup-gradle/post/index.js:6942:31)
      at ReadStream.emit (node:events:519:28)
      at emitErrorNT (node:internal/streams/destroy:169:8)
      at errorOrDestroy (node:internal/streams/destroy:238:7)
      at node:internal/fs/streams:272:9
      at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)
  Warning: Unhandled error in Gradle post-action - job will continue: Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
  Error: Cache upload failed because file read failed with EBADF: bad file descriptor, read
      at ReadStream.<anonymous> (/runner/_work/_actions/gradle/actions/v3/dist/setup-gradle/post/index.js:6942:31)
      at ReadStream.emit (node:events:519:28)
      at emitErrorNT (node:internal/streams/destroy:169:8)
      at errorOrDestroy (node:internal/streams/destroy:238:7)
      at node:internal/fs/streams:272:9
      at FSReqCallback.wrapper [as oncomplete] (node:fs:682:5)
  Warning: Failed to save cache entry with path '/home/runner/.gradle/caches/transforms-4/*/
  /home/runner/.gradle/caches/*/transforms/*/' and key: gradle-transforms-v1-baba20cb81b879353fe47a4fd1b135c0: Error: Cache service responded with 429 during upload chunk.
  Caching Gradle User Home with cache key: gradle-home-v1|Linux|utest[3783055aed77ffafca7bf4bbadee0d0e]-65e82f5b85071fa8cabc13c295691956bb34e456
  /bin/tar --posix -cf cache.tzst --exclude cache.tzst -P -C /runner/_work/xxx-groundup-android/xxx-groundup-android --files-from manifest.txt --use-compress-program zstdmt
  Failed to save cache entry with path '/home/runner/.gradle/caches,/home/runner/.gradle/notifications,/home/runner/.gradle/.setup-gradle' and key: gradle-home-v1|Linux|utest[3783055aed77ffafca7bf4bbadee0d0e]-65e82f5b85071fa8cabc13c295691956bb34e456: ReserveCacheError: Unable to reserve cache with key gradle-home-v1|Linux|utest[3783055aed77ffafca7bf4bbadee0d0e]-65e82f5b85071fa8cabc13c295691956bb34e456, another job may be creating this cache. More details: Cache already exists. Scope: refs/heads/test/upgrade-ge-plugin-0613, Key: gradle-home-v1|Linux|utest[3783055aed77ffafca7bf4bbadee0d0e]-65e82f5b85071fa8cabc13c295691956bb34e456, Version: efbc4f98d90c3a37d4c88199cd0a027f9a903840cd0ec083c3af7c7fd4363155
Generating Job Summary
Completed post-action step

Both of the scenarios are showing as warnings showing in the github annotations of summary.
So basically when we have many jobs, we're getting a long warning list. and it seems not clear if the warnings are need to be fixed or not. By checking our cache hit, it seems works fine, however, the long warnings looks not clear if it needs to be fixed or not. Any suggestion?

@bigdaz
Copy link
Member

bigdaz commented Jun 27, 2024

The Failed to save: Unable to reserve cache with key message is nothing to be concerned about: this often happens if you re-run a build with the same Git hash so the cache entry already exists.

The other messages indicate a general issue with the GitHub Actions cache. Assuming you're running GitHub Enterprise (and not using the public github.com) then this is something your infrastructure team will need to deal with.

The best and simplest test is to use a workflow with actions/cache@v4 to save something to the cache. This workflow doesn't need to use setup-gradle at all.

@bigdaz bigdaz closed this as completed Jun 27, 2024
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

2 participants