fix(argocd): extract revision from multi-source application revisions[]#8810
Open
vemulaanvesh wants to merge 2 commits intoapache:mainfrom
Open
fix(argocd): extract revision from multi-source application revisions[]#8810vemulaanvesh wants to merge 2 commits intoapache:mainfrom
vemulaanvesh wants to merge 2 commits intoapache:mainfrom
Conversation
rbstp
requested changes
Mar 25, 2026
ArgoCD multi-source applications (spec.sources[]) store one revision per
source in a revisions[] array on history entries and operationState.
The existing extractor only read the single-source revision field, which
is always empty for multi-source apps, so cicd_deployment_commits was
never populated and ArgoCD deployments were invisible to DORA metrics.
Changes:
- sync_operation_extractor.go
- Add Revisions []string and Sources []ArgocdApiSyncSource fields to
ArgocdApiSyncOperation to deserialise multi-source payloads.
- Add Revisions []string to SyncResult for operationState entries.
- Call resolveMultiSourceRevision() when revision is empty, both for
history entries and for operationState.
- Add resolveMultiSourceRevision(): prefers the revision whose source URL
belongs to a known git hosting service (GitHub, GitLab, Bitbucket, Azure
DevOps, Gitea, Forgejo); falls back to any 40-hex commit SHA.
- Add isGitHostedURL() and isCommitSHA() helpers.
- application_extractor.go
- Add Sources []ArgocdApiApplicationSource to ArgocdApiApplication so
multi-source app metadata is deserialised.
- Resolve the primary git-hosted source from spec.sources[] when
spec.source.repoURL is empty, ensuring ArgocdApplication.RepoURL is
a browsable repository URL rather than a Helm chart registry address.
Fixes: multi-source ArgoCD apps produce 0 rows in cicd_deployment_commits
Relates-to: apache#5207
Made-with: Cursor
cfc0c3d to
80f81ac
Compare
rbstp
requested changes
Mar 27, 2026
…n-hosts list gitea.internal.corp contains 'gitea.' which matches the known git host heuristic, so the test was actually hitting Pass 1, not the fallback. Replace with git.acme-corp.internal which has no known-host prefix, no chart-registry prefix, and no .git suffix, so resolveMultiSourceRevision genuinely falls through to the SHA-shape fallback (Pass 2). Made-with: Cursor
Contributor
|
lgtm |
rbstp
approved these changes
Mar 28, 2026
Author
|
@rbstp can merge this ? |
Contributor
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
ArgoCD multi-source applications (those using
spec.sources[]instead ofspec.source) store one revision per source in arevisions[]array on both history entries andoperationState. The existing extractor only read the single-sourcerevisionfield, which is always empty for multi-source apps.Impact:
cicd_deployment_commitswas never populated for multi-source apps, so ArgoCD deployments were invisible to DORA Deployment Frequency and Lead Time for Changes metrics.Relates to: #5207
Root cause
The extractor set
syncOp.Revision = apiOp.Revision(empty string), causingconvertSyncOperationsto skip thecicd_deployment_commitswrite (if syncOp.Revision != "").Changes
sync_operation_extractor.goRevisions []stringandSources []ArgocdApiSyncSourcetoArgocdApiSyncOperationstruct.Revisions []stringto theSyncResultnested struct foroperationStateentries.revisionis empty, callresolveMultiSourceRevision()before any skip logic.resolveMultiSourceRevision()— picks the git commit SHA fromrevisions[]:application_extractor.goSources []ArgocdApiApplicationSourcetoArgocdApiApplication.spec.source.repoURLis empty, resolve the primary source fromspec.sources[]using the same git-host heuristic soArgocdApplication.RepoURLis set to the browsable git repo URL rather than a Helm registry address.Tests added (
sync_operation_extractor_test.go)TestResolveMultiSourceRevision_GitHubSourceWinsTestResolveMultiSourceRevision_GitLabSourceWinsTestResolveMultiSourceRevision_FallbackToAnySHATestResolveMultiSourceRevision_EmptyRevisions""TestResolveMultiSourceRevision_AllSemver""TestResolveMultiSourceRevision_SingleGitSHATestIsCommitSHATestIsGitHostedURLBackward compatibility
revisionis non-empty soresolveMultiSourceRevisionis not called.