Skip to content

fix: Add retry logic to ACR login in on-demand sync script#220

Merged
janboll merged 4 commits intoAzure:mainfrom
raelga:fix/sync-acr-login-retry
Apr 16, 2026
Merged

fix: Add retry logic to ACR login in on-demand sync script#220
janboll merged 4 commits intoAzure:mainfrom
raelga:fix/sync-acr-login-retry

Conversation

@raelga
Copy link
Copy Markdown
Contributor

@raelga raelga commented Apr 16, 2026

Summary

  • Adds a retry helper with exponential backoff (up to 4 retries with 2/4/8/16s waits)
  • Wraps both az acr login calls in on-demand.sh (copyImageFromRegistry and copyImageFromOciLayout) with retry
  • Fixes transient Ev2 image mirroring failures caused by managed identity token errors (JSON is invalid: Expecting value)

Context

During Ev2 deployments, sync.sh (generated from on-demand.sh) runs as a separate process from the Ev2 wrapper script. The wrapper defines its own az_retry function with retry logic, but sync.sh does its own az acr login without any retry. Transient Azure managed identity token issues cause the login to fail with JSON is invalid, which is recoverable on retry but currently causes the entire deployment step to fail.

Test plan

  • Verify script syntax: bash -n pipelines/types/on-demand.sh
  • Downstream: bump ARO-Tools in sdp-pipelines, regenerate test fixtures

The az acr login command can fail transiently with managed identity
token errors (e.g. "JSON is invalid: Expecting value"). This wraps
both ACR login calls with exponential backoff retry (up to 5 attempts)
to handle these transient failures during Ev2 image mirroring.
Copilot AI review requested due to automatic review settings April 16, 2026 12:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves resiliency of the Ev2 on-demand image mirroring script by adding a generic retry helper and applying it to az acr login calls to mitigate transient managed identity/token failures.

Changes:

  • Added a retry helper with exponential backoff to pipelines/types/on-demand.sh.
  • Wrapped az acr login in copyImageFromRegistry with the new retry helper.
  • Wrapped the ACR access token acquisition in copyImageFromOciLayout with the new retry helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pipelines/types/on-demand.sh Outdated
Comment thread pipelines/types/on-demand.sh Outdated
Without error handling, set -e causes the script to exit immediately
on a transient az failure instead of letting the retry function catch
it. Also add --only-show-errors to reduce noise during retries.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pipelines/types/on-demand.sh Outdated
Comment thread pipelines/types/on-demand.sh Outdated
Comment thread pipelines/types/on-demand.sh Outdated
Comment thread pipelines/types/on-demand.sh Outdated
…able

- Send retry error and progress messages to stderr
- Rename local variable from 'wait' to 'delay' to avoid shadowing the
  bash builtin
@raelga raelga requested a review from janboll April 16, 2026 15:23
Comment thread pipelines/types/on-demand.sh Outdated
Copilot AI review requested due to automatic review settings April 16, 2026 16:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@rachelvweber rachelvweber self-requested a review April 16, 2026 16:50
@raelga raelga requested a review from janboll April 16, 2026 17:11
@janboll janboll merged commit ababd02 into Azure:main Apr 16, 2026
2 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.

4 participants