fix(argoCD): avoid duplication of latest deployments#8861
Closed
antarasevich wants to merge 4 commits intoapache:mainfrom
Closed
fix(argoCD): avoid duplication of latest deployments#8861antarasevich wants to merge 4 commits intoapache:mainfrom
antarasevich wants to merge 4 commits intoapache:mainfrom
Conversation
3 tasks
rbstp
requested changes
Apr 28, 2026
|
|
||
| isOperationState := apiOp.Phase != "" | ||
|
|
||
| // *** THE FIX *** |
Contributor
There was a problem hiding this comment.
Suggested change
| // *** THE FIX *** |
Contributor
There was a problem hiding this comment.
Thanks for the contribution! Can you please remove the above comment, and fix the failing test.
Contributor
Author
|
invalid. To be updated |
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
Fix duplicate
ArgocdSyncOperationrecords caused by ArgoCD exposing the same completed sync in two places in its API response:status.history[]andstatus.operationState.Problem
ArgoCD includes the most recent completed sync in both:
status.history[]— the authoritative log of all past syncs, each withdeployedAtstatus.operationState— a mirror of the last operation, withstartedAtThe DevLake collector feeds both into the raw table. The extractor then processes each independently, using different timestamp fields as
DeploymentId:history[id=30]deployedAt2026-04-16T09:02:16Z1776330136operationStatestartedAt2026-04-16T09:02:15Z1776330135Because
startedAtanddeployedAtdiffer by one second (the sync duration), the two records get different primary keys and both are persisted — resulting in duplicate deployment entries in DORA metrics and deployment frequency charts.Fix
Extract the skip logic into a dedicated
isRedundantOperationState(phase string) boolfunction and call it from insideExtractbefore processing anyoperationStaterow.A
SucceededoperationStateis always already present instatus.history[]so it is skipped. In-flight (Running,Terminating) and failure (Failed,Error) states are not yet — or may never be — written to history, so they continue to be processed normally.Behaviour by phase
operationStatephasehistory[]?SucceededRunning/TerminatingFailed/Error(empty)Testing
Added unit tests for
isRedundantOperationStatecovering all phase variants. Verified against production ArgoCD API responses for multiple applications whereoperationState.phase = Succeeded— duplicateArgocdSyncOperationrecords are eliminated after the fix.Related
backend/plugins/argocd/tasks/sync_operation_extractor.go