fix(diff): pass AppNamespace to ManagedResources query#535
Merged
Conversation
aab0745 to
466681e
Compare
When ArgoCD is configured for multi-namespace applications (`application.namespaces` on the controller), the diff check's `ManagedResources` gRPC call omits `AppNamespace`. ArgoCD looks for the Application in argocd-server's own namespace, doesn't find it, and returns PermissionDenied — which `isAppMissingErr` silently swallows, returning an empty resource list. Every diff then reports "N added, 0 modified, 0 removed". Other ArgoCD calls in kubechecks (`Get`, `ResourceTree`) already pass `appNamespace`; this aligns `ManagedResources` with them. Reproduction with argocd CLI (same gRPC API): argocd app resources <app-name> # PermissionDenied argocd app resources <app-namespace>/<app-name> # succeeds Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Alex K <alex@nativeplatform.co.uk>
466681e to
68f38ed
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect diff output for Argo CD installations using “Applications in any namespace” by ensuring kubechecks includes the Application’s namespace when calling Argo CD’s ManagedResources gRPC API. This prevents Argo CD from defaulting the lookup to the argocd-server namespace (which can yield PermissionDenied and an empty resource set), which previously caused diffs to appear as “all added”.
Changes:
- Pass
AppNamespacealongsideApplicationNamein theManagedResourcesrequest used by the diff check.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
For ArgoCD instances configured for multi-namespace Applications, the diff check's
ManagedResourcesgRPC call omitsAppNamespace, so ArgoCD looks for theApplicationobject in argocd-server's own namespace and returnsPermissionDenied(the convention to avoid leaking existence). The error is then swallowed byisAppMissingErrinpkg/checks/diff/diff.go, returning an empty resource list. The downstream effect is that every diff reportsN added, 0 modified, 0 removedregardless of the actual change.Symptom
For any ArgoCD
Applicationwhosemetadata.namespaceis not the argocd-server's own namespace:N added, 0 modified, 0 removed./Deployment /myapprather than/Deployment my-ns/myapp), becauseDeduplicateTargetObjectscan't backfill the namespace whenliveObjsis empty.Reproduction
The argocd CLI uses the same gRPC API:
argocd-server logs from a multi-namespace setup:
confirming that PermissionDenied is returned because ArgoCD looked for the Application in its own namespace and didn't find it — RBAC isn't the gate, the missing field is.
Fix
Pass
AppNamespace: &request.App.NamespacealongsideApplicationName. Other ArgoCD gRPC calls already made by kubechecks includeappNamespace(Get,ResourceTree— visible in the same argocd-server logs from the kubechecks pod), so this alignsManagedResourceswith the rest of the kubechecks -> ArgoCD API surface.🤖 Generated with Claude Code