fix: Add retry logic to ACR login in on-demand sync script#220
Merged
janboll merged 4 commits intoAzure:mainfrom Apr 16, 2026
Merged
fix: Add retry logic to ACR login in on-demand sync script#220janboll merged 4 commits intoAzure:mainfrom
janboll merged 4 commits intoAzure:mainfrom
Conversation
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.
There was a problem hiding this comment.
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
retryhelper with exponential backoff topipelines/types/on-demand.sh. - Wrapped
az acr loginincopyImageFromRegistrywith the new retry helper. - Wrapped the ACR access token acquisition in
copyImageFromOciLayoutwith the new retry helper.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
There was a problem hiding this comment.
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.
janboll
requested changes
Apr 16, 2026
…able - Send retry error and progress messages to stderr - Rename local variable from 'wait' to 'delay' to avoid shadowing the bash builtin
rachelvweber
approved these changes
Apr 16, 2026
janboll
requested changes
Apr 16, 2026
rachelvweber
approved these changes
Apr 16, 2026
janboll
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
retryhelper with exponential backoff (up to 4 retries with 2/4/8/16s waits)az acr logincalls inon-demand.sh(copyImageFromRegistryandcopyImageFromOciLayout) with retryJSON is invalid: Expecting value)Context
During Ev2 deployments,
sync.sh(generated fromon-demand.sh) runs as a separate process from the Ev2 wrapper script. The wrapper defines its ownaz_retryfunction with retry logic, butsync.shdoes its ownaz acr loginwithout any retry. Transient Azure managed identity token issues cause the login to fail withJSON is invalid, which is recoverable on retry but currently causes the entire deployment step to fail.Test plan
bash -n pipelines/types/on-demand.sh