Fix | repo-server-api render method does not pass ApiVersions in ManifestRequest#434
Merged
dag-andersen merged 7 commits intoJun 6, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the repo-server-api render path so it mirrors real Argo CD behavior by querying the destination cluster for KubeVersion and supported ApiVersions, then populating those fields on every ManifestRequest sent to the repo-server. This ensures Helm rendering sees a correct .Capabilities (notably .Capabilities.APIVersions) and avoids silently omitting resources gated on API availability.
Changes:
- Added Kubernetes discovery helpers to retrieve server version and available API group/versions.
- Threaded
kubeVersionandapiVersionsthrough the repo-server rendering pipeline and set them onManifestRequest. - Updated unit tests to match the updated
buildManifestRequestForSourcesignature.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pkg/k8s/discovery.go | Adds GetServerVersion() and GetAPIVersions() discovery helpers used to populate manifest rendering capabilities. |
| pkg/reposerverextract/extract.go | Fetches kube/api versions once per run and passes them into request construction for repo-server rendering. |
| pkg/reposerverextract/appofapps.go | Applies the same kube/api version propagation for app-of-apps traversal rendering. |
| pkg/reposerverextract/extract_test.go | Updates test call sites for the new buildManifestRequestForSource parameters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (c *Client) GetServerVersion() (string, error) { | ||
| v, err := c.discoveryClient.ServerVersion() | ||
| if err != nil { | ||
| return "", fmt.Errorf("failed to get server version: %w", err) |
Comment on lines
+30
to
+34
| seen := make(map[string]bool) | ||
| var apiVersions []string | ||
| for _, apiResourceList := range apiResourceLists { | ||
| if seen[apiResourceList.GroupVersion] { | ||
| continue |
Comment on lines
+104
to
+107
| apiVersions, err := argocd.K8sClient.GetAPIVersions() | ||
| if err != nil { | ||
| return nil, nil, time.Since(startTime), fmt.Errorf("failed to get API versions: %w", err) | ||
| } |
Comment on lines
102
to
103
| req, streamDir, cleanup, err := buildManifestRequestForSource(app, contentSources[0], refSources, hasMultipleSources, branchFolder, nil, "", "", nil) | ||
| require.NoError(t, err) |
Comment on lines
509
to
513
| creds *RepoCreds, | ||
| prRepo string, | ||
| kubeVersion string, | ||
| apiVersions []string, | ||
| ) (request *repoapiclient.ManifestRequest, streamDir string, cleanup func(), err error) { |
Comment on lines
100
to
103
| assert.False(t, hasMultipleSources) | ||
|
|
||
| req, streamDir, cleanup, err := buildManifestRequestForSource(app, contentSources[0], refSources, hasMultipleSources, branchFolder, nil, "") | ||
| req, streamDir, cleanup, err := buildManifestRequestForSource(app, contentSources[0], refSources, hasMultipleSources, branchFolder, nil, "", "", nil) | ||
| require.NoError(t, err) |
a2e1dfc to
2932d17
Compare
…festRequest Query the cluster for KubeVersion and ApiVersions once per render run and populate them on every ManifestRequest sent to the Argo CD repo server. This ensures Helm charts that conditionally render resources based on .Capabilities.APIVersions (e.g. ServiceMonitor, VirtualService) produce the same output as a real ArgoCD sync. New helpers added to pkg/k8s/discovery.go: - GetServerVersion() – wraps discoveryClient.ServerVersion() - GetAPIVersions() – returns all unique GroupVersion strings from the cluster Both RenderApplicationsFromBothBranches and RenderApplicationsFromBothBranchesWithAppOfApps now fetch these values and thread them through renderApp → buildManifestRequestForSource. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2932d17 to
a0e5763
Compare
Comment on lines
+464
to
+469
| configMismatch := currentClusterConfig != "" && currentClusterConfig != requiredClusterConfig | ||
|
|
||
| if rbacMismatch || configMismatch { | ||
| reason := "RBAC configuration mismatch" | ||
| if configMismatch { | ||
| reason = fmt.Sprintf("Argo CD config mismatch: current=%s, required=%s", currentClusterConfig, requiredClusterConfig) |
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.
Why
When using
--render-method repo-server-api, theManifestRequestsent to the Argo CD repo server did not populateKubeVersionorApiVersions. Helm therefore rendered charts without the destination cluster capabilities, so templates gated on available APIs, such asServiceMonitor,PrometheusRule, orVirtualService, could be silently omitted from the diff output.In a real Argo CD deployment, the application controller discovers the destination cluster Kubernetes version and API group versions before rendering and passes those values to the repo server. This PR mirrors that behavior for the repo-server-api render method.
Fixes #432.
What changed
pkg/k8s/discovery.go:GetServerVersion()returns the cluster GitVersion used forManifestRequest.KubeVersion.GetNamespacedScopedResourcesAndAPIVersions()discovers namespaced resources and API group versions in a single pass.pkg/reposerverextract/extract.goandpkg/reposerverextract/appofapps.go:ManifestRequest.manifestRequestRenderContextto avoid extending an already long positional argument list.pkg/reposerverextract/extract_test.goto assert thatKubeVersionandApiVersionsare copied onto the request..Capabilities.APIVersions:Testing
go test ./pkg/k8s ./pkg/reposerverextractgo test ./integration-test -run TestSingleCasemake run-integration-tests-go-with-repo-server-api