fix: re-resolve symbolic target revisions on sync retry#26925
fix: re-resolve symbolic target revisions on sync retry#26925rohansood10 wants to merge 1 commit intoargoproj:masterfrom
Conversation
When a sync operation fails and retries, symbolic refs like HEAD or branch names were not re-resolved, causing the retry to use the originally-resolved commit SHA which could be months old. This led to silent rollbacks of cluster resources to stale states. The retry logic only cleared the resolved revision when Retry.Refresh was explicitly set to true. For the common case where Retry.Refresh is false (the default), the stale SHA persisted across retries. Fix by also clearing the resolved revision on retry when the target revision is a symbolic ref (not a 40-character hex SHA), forcing re-resolution to the latest commit. Literal SHA target revisions are preserved since they always point to the same commit. Fixes argoproj#26530 Signed-off-by: Rohan Sood <56945243+rohansood10@users.noreply.github.com>
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #26925 +/- ##
=======================================
Coverage 63.16% 63.17%
=======================================
Files 414 414
Lines 56461 56480 +19
=======================================
+ Hits 35664 35681 +17
- Misses 17427 17430 +3
+ Partials 3370 3369 -1 ☔ View full report in Codecov by Sentry. |
|
@rohansood10, when implementing the Correct if I am wrong, but this change practically does the refresh regardless of the option's value, right? |
|
Good question - and you're right to flag this. The change here is intentionally scoped narrower than toggling What this does: when the target revision is a symbolic ref (HEAD, branch name, tag) rather than a literal SHA, it clears the resolved revision on retry so it gets re-resolved. It does NOT change the The distinction is: re-resolving a symbolic ref to its current SHA is a lightweight git operation, while That said, I see the concern about changing default retry behavior. Would it be cleaner to gate this behind a new sync option like cc the discussion at #11494 (comment) |
Can you elaborate on how is this possible? I do not see the connection with this described behavior from #26530.
Have you maybe forgot to push your full change set? I see it does the exact same thing as Was any AI assistant used to produce the contribution? |
|
Sure - the scenario from #26530 is:
The issue reporters saw this in production with HA mode where retries can be delayed. The fix specifically targets symbolic refs - literal SHAs are preserved since they're already pinned. Regarding the opt-in concern - you're right that this changes default behavior for symbolic refs. Would gating it behind |
|
Hmm. I am still not convinced this is the culprit.
See my question above. How is this different from what the flag does already (except that you skip SHAs)? |
|
Yeah fair question. Looking at the issue again, the reporters describe it as happening in HA setups with auto-sync + retry, but the exact sequence of how the cluster ended up ahead of the retried revision isn't fully clear from the logs they shared. You're right that if the sync was failing continuously, nothing newer would have been deployed through ArgoCD, so the retry applying the original commit wouldn't technically be a rollback. The scenario where it becomes dangerous is if something else deployed a newer version in the meantime (manual kubectl apply, another sync that succeeded, etc.) and then the retry fires with the old SHA. I'm less certain now that this is the right fix for #26530 specifically. Might be worth getting more detail from the reporters about what exactly happened in their case. Happy to close this if the consensus is that Retry.Refresh already covers the legitimate use case. |
Fixes #26530
When a sync with
targetRevision: HEADfails and retries, the retry reuses the originally-resolved commit SHA instead of re-resolving HEAD. If HEAD has moved (which it usually has), the retry applies manifests from the old commit — potentially rolling back the cluster to a stale state.The fix clears the resolved revision on retry when the target is a symbolic ref (HEAD, branch name, tag). Literal SHAs are left alone since they're already pinned. Uses the existing
git.IsCommitSHA()helper to distinguish.Relates to #23547