Repository navigation
feat(bundle): multi-tenant Argo deploy options - #1656
Conversation
Adds a reserved --set deployer:<key>=<value> vocabulary (namePrefix, destinationServer, project, cascadeDelete) parameterizing generated Argo CD Applications for multi-tenant and remote-cluster installs. Bundle-time for both argocd and argocd-helm deployers; argocd-helm additionally exposes the string keys at install time via helm --set deployer.<key>=... with baked defaults in values.yaml. Child-only scoping for namePrefix/destinationServer/project; the parent app-of-apps stays on the control-plane cluster. cascadeDelete adds resources-finalizer.argocd.argoproj.io to parent and children. Unknown keys, invalid values, non-Argo deployers, and the typed override path are rejected fail-closed with ErrCodeInvalidRequest. Fixes: #1625 Fixes: #1628 Signed-off-by: Mark Chmarny <[email protected]>
Recipe evidence checkNo leaf overlays affected by this PR. This gate is warning-only and never blocks merge. |
Coverage Report ✅
Coverage BadgeMerging this branch changes the coverage (1 decrease, 4 increase)
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds reserved Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Review-fix wave for the --set deployer:<key> vocabulary (PR #1656): - Quote templated scalars (name/project/server) in the argocd child Application template so YAML reserved scalars round-trip as strings. - Tighten destinationServer charset (no quotes/spaces/control chars) via new exported ValidateDestinationServer; ValidateNamePrefix exported and applied at both generator boundaries. - Emit values.schema.json in argocd-helm bundles: unknown or malformed deployer.* keys fail at helm install/template time (fail closed). - Prepend a template guard to every argocd-helm child: install-time deployer.namePrefix overrides that exceed Helm's 53-char release-name cap or collide with the parent Application name fail the render; matching bundle-time checks added in both deployers (argocd.HelmReleaseNameMaxLen). - Enforce the reserved 'deployer' component name / override key at registry load for embedded and external --data registries alike (recipe.ReservedDeployerKey, constant-equality test in bundler/config). - Docs: remote-destination prerequisites (cluster registration, project permissions), name limits, and the values.schema.json gate. - Nitpicks: sorted deployer option key iteration for deterministic errors; concrete DNS-1123 violation in project errors; upfront NamePrefix validation covering zero-folder recipes. Signed-off-by: Mark Chmarny <[email protected]>
|
Fixed:
Not changed — destination-namespace support: the consensus on #1625 explicitly deferred namespace remapping pending a concrete variant (per-tenant prefix vs. single shared namespace) — Full gate ( |
njhensley
left a comment
There was a problem hiding this comment.
📋 Multi-persona review — PR #1656 · feat(bundle): multi-tenant Argo deploy options
Method: 4 persona passes (Correctness · Security · Domain/Architecture · Test-coverage/Operability), each finding independently confirmed or refuted by a senior meta-reviewer against the resolved code. Line links pinned to head 6e75d979.
Tier legend: 🔴 Blocker · 🟠 Major · 🟡 Minor · 🔵 Nitpick · ✅ Confirmed non-issue
Overall assessment — Approve with comments
This is a high-quality, thoroughly-tested PR. The security-sensitive surface — user values rendered into Argo Application YAML — is handled well: the bundle-time path validates through an allowlist (ParseArgoDeployerOptions) and double-escapes with printf "%q"; the argocd-helm path emits single-quoted scalars with a schema that bans quotes/whitespace. No injection, no blockers, no majors. The finalizer-on-both-parent-and-children cascade model, the "children-only / parent-stays-in-cluster-default" app-of-apps design, the reserved-key layering seam with its cross-package equality test, and determinism (struct-ordered values.schema.json with a byte-golden) are all correct.
The one theme worth a follow-up: the argocd-helm install-time values.schema.json is a hand-rolled, weaker mirror of the bundle-time Go validators, so a value rejected at aicr bundle can slip through at helm install. Both instances (inline) are low blast-radius — bad value → child Application fails to sync, no crash, no breakout — hence Minor, but they're real drift sharing one root cause.
Summary-only notes (land on unchanged context / non-code)
- 🔵 CI helm fragility (
.github/actions/go-test/action.yml): the install-time guard/schema tests (TestHelmTemplate_*)t.Skipwhen helm is absent, and the go-test action installs only Go + envtest. They run today only becauseubuntu-latestships helm ambiently (unpinned) — unlike the repo'ssetup-build-toolswhich pins a version. Not a live gap, but a pinnedazure/setup-helmstep (or a CI env that makes absence fail rather than skip) would keep the safety net from silently disappearing. - 🔵 PR-description wording: "argocd deployer default output is byte-identical" — the goldens now quote scalars (
name: "gpu-operator",project: "default",server: "https://…"), so it's semantically equivalent, not byte-identical. Worth softening the claim (the%qquoting is also what makes the non-helm path injection-safe, so it's a good change). - 🔵 Docs: consider a one-liner that (a)
deployer:destinationServersupports onlyspec.destination.server, notdestination.name(name-registered clusters won't resolve), and (b)cascadeDelete=truebakes theresources-finalizer, which blockskubectl delete applicationif Argo CD is already gone (the classic stuck-Terminatingtrap).
✅ Confirmed non-issues (checked and cleared)
- YAML / Helm-template injection — clean on both paths. Bundle-time renders via
printf "%q"on pre-validated inputs; install-time uses single-quotedyaml.Nodescalars with schema-banned quotes/whitespace;{{…}}in a.Valueslookup is emitted as inert text (Helm is single-pass). ThechildNameGuardprintfinterpolates only registry-controlledcomponentName(%q) + a constant. - Finalizer
strings.Replaceinjection — anchor" namespace: argocd\nspec:"occurs exactly once inparentAppTemplate; the!Contains(ResourcesFinalizer)fail-loud guard is sound. - Length/collision math — Go
> 53and guardgt (len …) 53agree (no off-by-one); theappName | default "aicr-stack"fallback matches across guard, parent template, and the Go collision check. - Cross-deployer parity — the four options render equivalently across
argocdandargocd-helm; cascadeDelete is bundle-time-only in both. - Determinism —
values.schema.jsonis struct-ordered and pinned by a byte-golden (TestBundleGolden_HelmAndManifestOnly). - Fail-closed integrity —
argoDeployerOptions()runs unconditionally before the deployer switch; rejects typed (--set-json/--set-file) overrides, unknown keys, and thedeployer:prefix on non-Argo deployers; registry guard fails closed for embedded +--dataregistries; cross-package constant equality pinned. - "multi-tenant" scope — correctly delivers per-tenant naming/placement, not AppProject RBAC isolation (honestly documented in the
Projectfield comment).
Summary
| Tier | Count | Items |
|---|---|---|
| 🔴 Blocker | 0 | — |
| 🟠 Major | 0 | — |
| 🟡 Minor | 2 | install-time schema accepts credentialed destinationServer; install-time project schema looser than DNS-1123 |
| 🔵 Nitpick | 5 | opaque cascadeDelete install error · 53-cap on non-Helm children · duplicated default literals · CI helm fragility · "byte-identical" wording (+ optional doc notes) |
Recommendation: Approve with comments. No blockers or majors. The two Minors share one root cause — the install-time values.schema.json diverging from the Go validators — and are worth a follow-up (ideally generating one from the other); everything else is optional polish.
🤖 Generated with multi-persona review + adversarial meta-review.
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/bundler/deployer/argocd/argocd.go (1)
437-445: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a project-specific validator message
ValidateAppNamehardcodesinvalid app name ..., sog.Projectwill report the wrong field. Add a project-specific wrapper or make the helper accept a label, and apply the same fix inpkg/bundler/deployer/argocdhelm/argocdhelm.go.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/bundler/deployer/argocd/argocd.go` around lines 437 - 445, The validation path currently reports the wrong field because ValidateAppName hardcodes an app-name error message while being used for g.Project. Update the Argocd deployer validation flow to use a project-specific validator message, either by adding a wrapper or by changing bundlercfg.ValidateAppName to accept a field label and using it for g.Project; apply the same change in ArgocdHelm validation so both Argocd and ArgocdHelm report the correct field name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/bundler/config/argo_deployer.go`:
- Around line 142-147: The deployer project override handling in the config
parsing logic currently validates an empty string as an invalid DNS subdomain,
which prevents unset overrides from working. Update the deployerKeyProject
branch in the argo deployer config parsing to treat "" as unset, consistent with
the namePrefix and destinationServer behavior, so that Generator.project() can
fall back to default when opts.Project is empty. Keep the validation only for
non-empty values and preserve the existing opts.Project assignment for valid
inputs.
In `@pkg/bundler/deployer/argocd/templates/application.yaml.tmpl`:
- Around line 40-41: The destination block in the Application template is
inconsistent because `namespace` is still emitted unquoted while `name`,
`project`, and `server` use explicit quoting. Update the template in the
`application.yaml.tmpl` destination section so `namespace` is escaped the same
way as the other fields, keeping the quoting policy uniform and aligned with the
existing `printf "%q"` handling.
---
Outside diff comments:
In `@pkg/bundler/deployer/argocd/argocd.go`:
- Around line 437-445: The validation path currently reports the wrong field
because ValidateAppName hardcodes an app-name error message while being used for
g.Project. Update the Argocd deployer validation flow to use a project-specific
validator message, either by adding a wrapper or by changing
bundlercfg.ValidateAppName to accept a field label and using it for g.Project;
apply the same change in ArgocdHelm validation so both Argocd and ArgocdHelm
report the correct field name.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 5c1e245e-085e-47b6-a789-b33f11217c97
📒 Files selected for processing (29)
docs/user/cli-reference.mdpkg/bundler/config/argo_deployer.gopkg/bundler/config/argo_deployer_test.gopkg/bundler/deployer/argocd/argocd.gopkg/bundler/deployer/argocd/argocd_test.gopkg/bundler/deployer/argocd/templates/application.yaml.tmplpkg/bundler/deployer/argocd/testdata/helm_and_kustomize/001-cert-manager/application.yamlpkg/bundler/deployer/argocd/testdata/helm_and_kustomize/002-my-kustomize-app/application.yamlpkg/bundler/deployer/argocd/testdata/helm_and_manifest_only/001-cert-manager/application.yamlpkg/bundler/deployer/argocd/testdata/helm_and_manifest_only/002-nodewright-customizations/application.yamlpkg/bundler/deployer/argocd/testdata/kustomize_only/001-my-kustomize-app/application.yamlpkg/bundler/deployer/argocd/testdata/mixed_component/001-gpu-operator/application.yamlpkg/bundler/deployer/argocd/testdata/mixed_component/002-gpu-operator-post/application.yamlpkg/bundler/deployer/argocd/testdata/mixed_with_pre/001-gpu-operator-pre/application.yamlpkg/bundler/deployer/argocd/testdata/mixed_with_pre/002-gpu-operator/application.yamlpkg/bundler/deployer/argocd/testdata/mixed_with_pre/003-gpu-operator-post/application.yamlpkg/bundler/deployer/argocd/testdata/readiness_gate/001-gpu-operator/application.yamlpkg/bundler/deployer/argocd/testdata/readiness_gate/002-gpu-operator-readiness/application.yamlpkg/bundler/deployer/argocdhelm/argocdhelm.gopkg/bundler/deployer/argocdhelm/argocdhelm_test.gopkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/templates/cert-manager.yamlpkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/templates/nodewright-customizations.yamlpkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/values.schema.jsonpkg/bundler/deployer/argocdhelm/testdata/mixed_component/templates/gpu-operator-post.yamlpkg/bundler/deployer/argocdhelm/testdata/mixed_component/templates/gpu-operator.yamlpkg/bundler/deployer/argocdhelm/testdata/readiness_gate/templates/gpu-operator-readiness.yamlpkg/bundler/deployer/argocdhelm/testdata/readiness_gate/templates/gpu-operator.yamlpkg/recipe/components.gopkg/recipe/components_test.go
- forbid @ in destinationServer schema pattern (embedded credentials) - tighten project schema pattern to exact per-label DNS-1123 subdomain form - document deployer.cascadeDelete as bundle-time only in values.yaml header and schema doc - soften 53-cap messages: Helm release name derivation applies to Helm-rendered children; cap kept uniform for one invariant - interpolate argocd.DefaultProject/DefaultDestinationServer into child templates instead of duplicated literals Signed-off-by: Mark Chmarny <[email protected]>
Signed-off-by: Mark Chmarny <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/bundler/deployer/argocdhelm/argocdhelm_test.go`:
- Around line 2207-2253: Extend TestValuesSchemaPatterns to also assert that the
generated schema keeps deployer.additionalProperties disabled; after
unmarshalling values.schema.json into valuesSchema, check the Deployer schema
field on schema.Properties.Deployer and fail the test if AdditionalProperties is
true. This should sit alongside the existing regex assertions so the test pins
both the pattern behavior and the fail-closed schema shape produced by
writeValuesSchema.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: d08f5527-5e40-49ab-8c55-3927c3811630
📒 Files selected for processing (12)
pkg/bundler/deployer/argocd/argocd.gopkg/bundler/deployer/argocdhelm/argocdhelm.gopkg/bundler/deployer/argocdhelm/argocdhelm_test.gopkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/templates/cert-manager.yamlpkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/templates/nodewright-customizations.yamlpkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/values.schema.jsonpkg/bundler/deployer/argocdhelm/testdata/helm_and_manifest_only/values.yamlpkg/bundler/deployer/argocdhelm/testdata/mixed_component/templates/gpu-operator-post.yamlpkg/bundler/deployer/argocdhelm/testdata/mixed_component/templates/gpu-operator.yamlpkg/bundler/deployer/argocdhelm/testdata/mixed_component/values.yamlpkg/bundler/deployer/argocdhelm/testdata/readiness_gate/templates/gpu-operator-readiness.yamlpkg/bundler/deployer/argocdhelm/testdata/readiness_gate/templates/gpu-operator.yaml
Signed-off-by: Mark Chmarny <[email protected]>
njhensley
left a comment
There was a problem hiding this comment.
✅ Re-approve on ba4f8fd3 — all review feedback addressed.
Verified the follow-up commits against my earlier findings:
- 🟡
destinationServercredential parity — schema pattern tightened to^https://[^'"\s@]+$, matching the bundle-timeValidateHTTPSURLcredential rejection. Pinned byTestValuesSchemaPatterns(https://u:p@host:6443now rejected). - 🟡
projectDNS-1123 parity — schema now enforces exact per-label form (≤63/label, no empty labels);a..bis rejected, matchingIsDNS1123Subdomain. - 🔵
cascadeDeleteUX — documented as bundle-time-only in the schema comment and thevalues.yamlinstall header. - 🔵 53-char cap message — reworded to be accurate for non-Helm children (uniform cap kept by design as a single invariant).
- 🔵 Duplicated defaults — now reference
argocd.DefaultProject/argocd.DefaultDestinationServer.
values.schema.json golden regenerated to match, and a new fail-open guard test asserts additionalProperties: false is emitted. No blockers, no majors. LGTM.
|
Three notes that do not anchor to changed lines: CI does not install Helm for unit tests. Validation-contract drift. The destinationServer/project/namePrefix findings on this PR are all instances of the install-time gate (schema pattern or template guard) diverging from the bundle-time Go validators — in both directions. A parity test would close the class: drive the same inputs through the Go validator and through PR body wording. The "byte-identical" claim for the argocd deployer is not accurate — the twelve argocd goldens each changed four scalars from unquoted to quoted (name, project, server, namespace). The output is semantically equivalent, not byte-identical; suggest rewording to avoid overstating the compatibility guarantee. |
Signed-off-by: Mark Chmarny <[email protected]>
Reject uppercase scheme and '@' anywhere in deployer destinationServer so the bundle-time validator exactly mirrors the install-time schema pattern; parity and parser tests extended; go-test README examples gain the new helm_version input. Signed-off-by: Mark Chmarny <[email protected]>
|
All three addressed, @yuanchen8911 — and the second one paid for itself immediately. CI Helm install — Validation-contract parity test — added as
The type-inference cases are in too ( PR body — reworded: the argocd output is semantically equivalent, not byte-identical (the hardening commits quote name/project/server/namespace; goldens re-pinned). |
|
Verified at 62f14ae: the CI gap and the parity-test recommendation from the earlier note are both addressed — the go-test action now installs the Helm version pinned in .settings.yaml and the live-render tests fail (rather than skip) when helm is missing in CI, and TestValidationContractParity drives the bundle-time Go validators and |
- coerce appName via toString in childNameGuard so --set appName=true (Helm type inference) no longer crashes eq at render time - forward the effective parent AppName to the inner argocd.Generator so its parent-collision check tests against this deployer's parent, not the inner nvidia-stack default - reject componentRefs named with the reserved deployer key at RecipeResult.PrepareAndValidate (CLI and API fail closed, disabled refs included) - mirror IsDNS1123Subdomain exactly for deployer project: drop the per-label 63-char cap (64+-char labels are legal k8s object names) and allow explicit-empty project/destinationServer at install time to reset to baked defaults - docs: qualify the argocd cleanup section for cascadeDelete bundles - docs: document --set-string for type-inferred deployer.* values Signed-off-by: Mark Chmarny <[email protected]>
|
Thanks for the verification, @yuanchen8911. The five remaining items from your list all landed in 40a4e0f (each thread has an inline reply with details): the |
|
/lgtm |
yuanchen8911
left a comment
There was a problem hiding this comment.
All review findings verified fixed at 40a4e0f — bundle-time and install-time validation confirmed aligned end-to-end (helm template matrix + Go validator probes), parity test and pinned-Helm CI in place, docs updated.
Signed-off-by: Mark Chmarny <[email protected]>
Summary
Adds a reserved
--set deployer:<key>=<value>vocabulary (namePrefix,destinationServer,project,cascadeDelete) that parameterizes generated Argo CD Applications for multi-tenant and remote-cluster installs — bundle-time for bothargocdandargocd-helmdeployers, plus install-timehelm --set deployer.<key>=...overrides forargocd-helm.Motivation / Context
Generated Argo Application wrapper fields (child names,
spec.destination.server,spec.project) were hardcoded, blocking installs of the same bundle across tenants, namespaces, and clusters; deleting the parent Application also left managed resources behind (no finalizer option). Design follows the consensus posted on both issues.Fixes: #1625
Fixes: #1628
Related: N/A
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)pkg/recipe)pkg/bundler,pkg/component/*)docs/,examples/)Implementation Notes
pkg/bundler/config/argo_deployer.go): unknowndeployer:keys, invalid values, non-Argo deployers, and the typed override path (--set-json/--set-file) are all rejected withErrCodeInvalidRequest. Thedeployername is reserved by a registry guard test.namePrefix/destinationServer/project: the parent app-of-apps stays on the Argo CD control-plane cluster in projectdefault— Application CRs are reconciled only from the cluster running Argo CD (apps-in-any-namespace broadens namespaces, not source clusters), and App-of-Apps is an admin-only pattern. Parent name remains covered by--app-name.cascadeDeleteaddsresources-finalizer.argocd.argoproj.ioto parent AND children (app deletion docs); bundle-time only, becausemetadata.finalizersis a list field that cannot round-trip as a Helm template expression.argocd-helminstall-time layering: baked values ship as chart defaults in the rootvalues.yamldeployer:map; child templates read.Values.deployer.*with nil-safe sprig defaults. A livehelm templatetest proves--set deployer.namePrefix=t-renderst-gpu-operator.name/project/server/namespacein theargocdtemplates (goldens re-pinned), so the YAML bytes differ by quoting only; parsed values are unchanged.argocd-helmdefault rendering is equivalent (fields templated with today's values as defaults).destinationServermust be a credential-freehttps://URL.Testing
Coverage deltas (branch vs origin/main):
pkg/bundler: 72.5% → 72.9% (+0.4%)pkg/bundler/config: 96.7% → 96.9% (+0.2%)pkg/bundler/deployer/argocd: 81.2% → 82.9% (+1.7%)pkg/bundler/deployer/argocdhelm: 81.8% → 81.8% (±0.0%)New tests: allowlist parser table tests, generator option/rejection tests for both deployers, typed-override rejection, registry reserved-key tripwire, live
helm templateoverride render.argocdgoldens unchanged;argocd-helmgoldens regenerated (changes confined to the three templated child fields +values.yamldeployer:block).Risk Assessment
Rollout notes: Backwards compatible — bundles generated without
deployer:options are semantically unchanged (scalar quoting differs inargocdoutput; parsed manifests identical). No migration needed.Checklist
make testwith-race)make lint)git commit -S) — GPG signing info