Fix infinite retry loop in SetResource.ps1 (missing $iterator increment) - #198
Open
madanmishra1223 wants to merge 1 commit into
Open
Fix infinite retry loop in SetResource.ps1 (missing $iterator increment)#198madanmishra1223 wants to merge 1 commit into
madanmishra1223 wants to merge 1 commit into
Conversation
UpdateLoop initializes $iterator to 1 but never increments it, so the loop guard ($iterator -le $maxIterations) stays true forever whenever Set-AzResource keeps failing. Instead of giving up after maxIterations attempts, the function retries indefinitely with a 5 second sleep between tries, hanging the pipeline task, and the "Failed to update resources" throw below the loop is unreachable. Increment $iterator in the catch block so the retry budget passed by the caller (-maxIterations 3) is honored and a persistent failure surfaces as an error instead of a hang. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree |
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.
Problem
UpdateLoopin.ci/scripts/SetResource.ps1is meant to retry a failingSet-AzResourcecall a bounded number of times:$iteratoris initialized to1but is never incremented. WhenSet-AzResourcekeeps failing,$successstays$falseand$iteratorstays1, so the guard($iterator -le $maxIterations)is always true.Consequences:
UpdateLoop -maxIterations 3 -resource $_) is ignored.throw "Failed to update resources"below the loop is unreachable on persistent failure, so a genuine failure is reported as a hung/timed-out job instead of a clear error.Fix
Increment
$iteratorin thecatchblock, so the loop honors-maxIterationsand a persistent failure exits via the existingthrow.Write-Host($_.Exception.Message) + $iterator++ Start-Sleep -Seconds 5One line changed; no behavior change on the success path (that path still
breaks on the first successful call).