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
cfc0c3d to
80f81ac
Compare
rbstp
requested changes
Mar 27, 2026
Contributor
|
lgtm |
rbstp
previously approved these changes
Mar 28, 2026
Author
|
@rbstp can merge this ? |
Contributor
Author
|
Hi @klesh can i get your eyes here to merge ? |
added 2 commits
April 1, 2026 11:48
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
…ployment_commits
Previously cicd_deployment_commits.repo_url was populated by reading
application.RepoURL in convertSyncOperations. For multi-source apps
_tool_argocd_applications.repo_url is empty when extractApplications
is skipped (DevLake's collector state cache omits it when no new
application raw data has been collected), causing the repo_url field
to fall back to the deployment-name placeholder and breaking DevLake's
commits_diff to PR linkage for DORA Lead Time metrics.
Fix: resolve the git repo URL during extractSyncOperations, which
always runs regardless of collector state. The resolved URL is stored
in a new ArgocdSyncOperation.RepoURL field and used as the primary
source in convertSyncOperations, with application.RepoURL as fallback.
Changes:
- models/sync_operation.go: add RepoURL varchar(500) field
- models/migrationscripts/: add migration 20260331 to ADD COLUMN
- tasks/sync_operation_extractor.go:
- add resolveGitRepoURL(singleSourceURL, sources): prefers known
git-hosting URLs from sources[], falls back to first non-chart URL
- populate syncOp.RepoURL after revision resolution
- tasks/sync_operation_convertor.go: use syncOp.RepoURL first, then
application.RepoURL, then deployment name as last resort
- tasks/sync_operation_extractor_test.go: 6 new tests for
resolveGitRepoURL covering single-source, multi-source, fallback,
all-chart, and empty inputs
Contributor
|
@rbstp, feel free to merge once all checks pass—I'm not close enough to the details to add anything else. |
032e1aa to
134c91f
Compare
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.