Skip to content

fix: retry sdkmanager install on transient download failures - #81

Merged
compscidr merged 1 commit into
mainfrom
fix/retry-sdkmanager-install
Aug 27, 2026
Merged

fix: retry sdkmanager install on transient download failures#81
compscidr merged 1 commit into
mainfrom
fix/retry-sdkmanager-install

Conversation

@compscidr

Copy link
Copy Markdown
Owner

Why

PR #80's Build JDK 17 job failed with:

[=====  ] 15% Downloading cmake-3.22.1-linux.zip
[=====  ] 15% Unzipping...
Warning: An error occurred while preparing SDK package CMake 3.22.1: Archive is not a ZIP archive.

The download from dl.google.com was truncated and sdkmanager tried to unzip the partial file. The same package installed fine in the JDK 21 job of the same run, so this was a network flake — but sdkmanager has no built-in download retry, so one bad download fails the whole image build.

What

Wrap the sdkmanager install RUN in an until loop that retries up to 3 times (15s apart). sdkmanager is idempotent — already-installed packages are skipped — so re-running the whole command is safe. The SDK's .temp download scratch dir is cleared between attempts so a corrupt partial archive isn't reused. After 3 failures the build still fails loudly with sdkmanager failed after 3 attempts.

Verification

  • Extracted the loop verbatim from the Dockerfile and ran it under bash -o pipefail against a mock sdkmanager:
    • fails twice then succeeds → exit 0 after 3 calls
    • always fails → exit 1 after exactly 3 calls
    • succeeds immediately → exit 0 after 1 call
  • docker build --check . → no warnings
  • Full local docker build --target android . succeeded; cmake/3.22.1, ndk/29.0.14206865, build-tools/37.0.0, platforms/android-36.1, and platform-tools all present in the resulting image.

🤖 Generated with Claude Code

https://claude.ai/code/session_012jviQGmp5ey58RmYqoPssC

sdkmanager has no download retry. A truncated download from
dl.google.com (seen in the PR #80 JDK 17 build as "An error occurred
while preparing SDK package CMake 3.22.1: Archive is not a ZIP archive")
fails the whole image build even though the Dockerfile is fine.

sdkmanager is idempotent, so wrap the install in an until-loop that
retries up to 3 times, clearing the SDK's .temp download dir between
attempts so a corrupt partial archive is not reused.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012jviQGmp5ey58RmYqoPssC
Copilot AI lite review requested due to automatic review settings August 27, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The retry loop is bounded, preserves failure behavior after 3 attempts, and the change is localized to the intended sdkmanager install step.

Pull request overview

This PR improves the reliability of Android SDK component installation during image builds by adding a retry mechanism around sdkmanager to handle transient/truncated downloads from dl.google.com.

Changes:

  • Wraps the sdkmanager package install step in an until loop with up to 3 attempts and 15s backoff.
  • Clears the SDK’s temporary download directory between attempts to avoid reusing corrupted partial downloads.
  • Emits explicit retry/failure messages and fails the build after the final attempt.
File summaries
File Description
Dockerfile Adds a bounded retry loop around sdkmanager installs and clears .temp between retries to mitigate transient download truncations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@compscidr
compscidr merged commit 13ea353 into main Aug 27, 2026
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants