Repository navigation
fix(bundler): tracked -post release for vendored mixed components - #2061
Conversation
Recipe evidence checkNo leaf overlays affected by this PR. This gate is warning-only and never blocks merge. |
Coverage Report ✅
Coverage BadgeMerging this branch will decrease overall coverage
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:
📝 WalkthroughWalkthroughVendored mixed Helm components now emit recipe-side manifests in a separate Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@docs/user/bundling.md`:
- Around line 157-160: Update the vendored-hook cleanup guidance in the Helm
bundling documentation to remove the obsolete claim that post-manifest resources
remain after helm uninstall, since stripHelmHooks makes them regular tracked
templates. Replace it with the documented behavior for deleting the associated
Argo CD Application.
In `@pkg/bundler/deployer/localformat/vendor_wrapper.go`:
- Around line 138-150: Rename the helper injectPostInstallHooks to a
lifecycle-neutral name such as injectPostLifecycleHooks, and update every
corresponding TestInjectPostInstallHooks_* test name and reference to match.
Preserve the existing post-install and post-upgrade injection behavior.
- Line 240: Review the generated recipe-side manifests associated with the
helm.sh/hook annotation in vendor_wrapper.go, including DaemonSets and custom
resources, to confirm they can be safely deleted and recreated during
post-upgrade. Adjust the manifests or hook behavior where necessary to preserve
upgrade correctness, and document any expected service disruption.
🪄 Autofix
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: ab2b17aa-9bac-4c8f-b53d-d671e7871187
📒 Files selected for processing (6)
docs/user/bundling.mddocs/user/cli-reference.mdpkg/bundler/deployer/localformat/hooks.gopkg/bundler/deployer/localformat/vendor_wrapper.gopkg/bundler/deployer/localformat/vendor_wrapper_test.gopkg/bundler/deployer/localformat/vendor_write_test.go
cb5d867 to
0920e5a
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/localformat/vendor_wrapper.go`:
- Line 240: Update the hook annotation handling around annos["helm.sh/hook"] to
validate helm.sh/hook-delete-policy: require before-hook-creation whenever a
Helm hook is configured, and reject policies that omit it, including hook-failed
alone. Document the incompatible policy requirement alongside the validation.
- Line 240: Update the vendored mixed-component flow in vendor_folder.go to call
stripHelmHooks() immediately after injectPostInstallHooks(), ensuring hook
annotations are removed before the bundle is passed downstream while preserving
the existing folder-level ordering.
🪄 Autofix
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: 3b02cdf2-58a2-4f80-a3aa-7319181fbb55
📒 Files selected for processing (6)
docs/user/bundling.mddocs/user/cli-reference.mdpkg/bundler/deployer/localformat/hooks.gopkg/bundler/deployer/localformat/vendor_wrapper.gopkg/bundler/deployer/localformat/vendor_wrapper_test.gopkg/bundler/deployer/localformat/vendor_write_test.go
| return false | ||
| } | ||
| annos["helm.sh/hook"] = "post-install" | ||
| annos["helm.sh/hook"] = "post-install,post-upgrade" |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 4 \
'helm\.sh/hook-delete-policy:\s*hook-failed|helm\.sh/resource-policy:\s*keep' .Repository: NVIDIA/aicr
Length of output: 149
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="pkg/bundler/deployer/localformat/vendor_wrapper.go"
printf '%s\n' '--- target file context ---'
sed -n '200,270p' "$file"
printf '%s\n' '--- relevant symbols and call sites ---'
rg -n -C 5 \
'hook-delete-policy|resource-policy|post-install|post-upgrade|vendor_wrapper|VendorWrapper' \
pkg go.mod Makefile .github 2>/dev/null || true
printf '%s\n' '--- Helm version declarations ---'
rg -n -i 'helm([ _-]*(version|v))?|helm.sh/helm|helm upgrade|helm install' \
go.mod go.sum Makefile README.md .github pkg 2>/dev/null || trueRepository: NVIDIA/aicr
Length of output: 50368
🏁 Script executed:
#!/bin/bash
set -euo pipefail
file="pkg/bundler/deployer/localformat/vendor_wrapper.go"
printf '%s\n' '--- target implementation ---'
cat -n "$file" | sed -n '150,270p'
printf '%s\n' '--- tests for localformat and wrapper behavior ---'
git ls-files | rg '(^|/)(vendor_wrapper|localformat|bundler|deployer).*(_test\.go$|\.go$)' | head -80
rg -n -C 6 \
'hook-delete-policy|helm\.sh/hook|post-upgrade|post-install|localformat' \
--glob '*_test.go' --glob '*.go' .
printf '%s\n' '--- dependency and tool configuration ---'
rg -n -i 'helm|chart|kubernetes' go.mod go.sum Makefile .github pkg 2>/dev/null | head -160Repository: NVIDIA/aicr
Length of output: 50368
🌐 Web query:
Helm chart hooks hook-failed before-hook-creation hook-delete-policy post-upgrade behavior supported Helm versions
💡 Result:
Helm chart hooks are managed via annotations and are supported across all standard Helm versions (Helm 2 and Helm 3) [1][2][3]. ### Hook Deletion Policies The helm.sh/hook-delete-policy annotation controls when Helm deletes hook resources [4][5]. If no policy is specified, the default behavior is before-hook-creation [4][2]. * before-hook-creation: Deletes the previous hook resource before a new hook is launched [1][4]. This is essential for ensuring idempotent upgrades and preventing "already exists" errors during subsequent runs [1][5]. * hook-succeeded: Deletes the resource immediately after the hook successfully executes [4][5]. * hook-failed: Deletes the resource if the hook fails during execution [4][5]. Note that if a hook fails, Helm may stop processing subsequent hooks [6]. In some versions, if multiple hooks are defined with hook-failed, a failure in one might leave preceding successfully executed hooks undeleted [6]. ### Post-Upgrade Hook Behavior The post-upgrade hook executes after Helm has performed the upgrade request for the release's resources [7][3]. Important nuances regarding post-upgrade include: * Ready State: For most resource types, "upgraded" means the Kubernetes API server has accepted the update [3]. For Job or Pod resources, Helm waits for the hook itself to reach a completion state [2]. * Deployment Timing: Helm's "post-upgrade" hook does not inherently wait for the underlying application's Deployment or StatefulSet pods to finish rolling out (i.e., becoming "Ready") unless specifically configured to do so [8]. If you need the hook to run only after your application pods are fully updated, you should use the --wait flag during the helm upgrade command [8][9]. ### Summary of Supported Versions These hook mechanisms are fundamental to Helm and are supported in both Helm 2 and Helm 3 [1][2][7]. While internal implementation details (such as the transition from Tiller in Helm 2 to client-side logic in Helm 3) have evolved, the annotation-based hook configuration remains consistent [1][4][2].
Citations:
- 1: https://helm.sh/docs/v2/developing_charts/charts_hooks/
- 2: https://v3-1-0.helm.sh/docs/topics/charts_hooks/
- 3: https://v2.helm.sh/docs/charts_hooks/
- 4: https://github.com/helm/helm-www/blob/main/docs/topics/charts_hooks.md
- 5: https://kubernetes.recipes/recipes/helm/helm-hook-delete-policy/
- 6: Hook delete policy of "hook-failed" not honored for preceding resource on a failure helm/helm#10279
- 7: https://helm.sh/docs/topics/charts_hooks/
- 8: https://stackoverflow.com/questions/74205161/helm-post-upgrade-hook-running-before-all-pods-upgraded
- 9: https://github.com/helm/helm/blob/827a960e/pkg/action/upgrade.go
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '210,260p' pkg/bundler/deployer/localformat/vendor_wrapper.go
rg -n -C 5 'hook-delete-policy|post-upgrade|post-install' --glob '*_test.go' --glob '*.go' .
rg -n -i 'helm|chart' go.mod go.sum MakefileRepository: NVIDIA/aicr
Length of output: 48867
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path("pkg/bundler/deployer/localformat/vendor_wrapper.go")
s = p.read_text()
required = [
'annos["helm.sh/hook"] = "post-install,post-upgrade"',
'if _, alreadySetPolicy := annos["helm.sh/hook-delete-policy"]; !alreadySetPolicy {',
'annos["helm.sh/hook-delete-policy"] = "before-hook-creation"',
]
for fragment in required:
assert fragment in s, f"missing implementation fragment: {fragment}"
# Model the exact policy branch without executing repository code.
def injected_policy(existing):
return existing if existing is not None else "before-hook-creation"
cases = {
None: "before-hook-creation",
"hook-failed": "hook-failed",
"hook-succeeded": "hook-succeeded",
"before-hook-creation,hook-succeeded": "before-hook-creation,hook-succeeded",
}
for existing, expected in cases.items():
actual = injected_policy(existing)
assert actual == expected, (existing, actual, expected)
print("implementation preserves an existing hook-delete-policy, including hook-failed")
print("implementation defaults only an absent hook-delete-policy to before-hook-creation")
PY
printf '%s\n' '--- focused tests and supported Helm pin ---'
sed -n '120,170p' pkg/bundler/deployer/localformat/vendor_wrapper_test.go
rg -n -i 'helm:' .settings.yaml .github tools Makefile 2>/dev/null | head -40Repository: NVIDIA/aicr
Length of output: 4457
🌐 Web query:
site:helm.sh/docs Helm v4.2.3 hook-delete-policy hook-failed before-hook-creation
💡 Result:
In Helm, the helm.sh/hook-delete-policy annotation determines when hook resources are deleted from the cluster [1][2]. These policies are used to manage the lifecycle of hook-created resources, which are not automatically tracked or garbage-collected as part of the primary release by default [1][2]. The available policy values are: - before-hook-creation: Deletes the previous hook resource before a new hook is launched [1][2]. This is the default behavior if no policy is specified [2]. - hook-succeeded: Deletes the resource after the hook executes successfully [1][2]. - hook-failed: Deletes the resource if the hook fails during execution [1][2]. You can combine these policies by providing them in a comma-separated list (e.g., "hook-succeeded,hook-failed") [2]. The "before-hook-creation" policy is particularly useful for ensuring that subsequent installations or upgrades do not fail due to an "already exists" error caused by a leftover resource from a previous release [3][4]. These mechanics remain consistent across Helm versions, including Helm 4.x [2].
Citations:
- 1: https://v3-1-0.helm.sh/docs/topics/charts_hooks/
- 2: https://helm.sh/docs/topics/charts_hooks/
- 3: https://helm.sh/docs/v2/developing_charts/charts_hooks/
- 4: https://v2.helm.sh/docs/charts_hooks/
🌐 Web query:
Helm v4.2.3 source hook-delete-policy before-hook-creation hook-failed
💡 Result:
In Helm v4.2.3, the helm.sh/hook-delete-policy annotation manages the lifecycle of hook resources [1][2][3]. The three supported policies are: - before-hook-creation: Deletes the existing hook resource before a new hook is launched. This is the default behavior if no annotation is provided [1][2]. - hook-succeeded: Deletes the hook resource after the hook has successfully completed execution [1][2]. - hook-failed: Deletes the hook resource if the hook fails during execution [1][2]. Regarding the behavior of before-hook-creation and hook-failed specifically: 1. Relationship: You can combine these policies (e.g., helm.sh/hook-delete-policy: before-hook-creation,hook-failed) to ensure that failed resources from a previous execution are cleaned up before a new one starts, while also removing current resources if they fail [1][4][5]. 2. Known Limitation: A widely reported behavior in Helm is that the hook-failed policy does not always trigger a cleanup of preceding hook resources if a later hook in the same operation fails [6][7]. Helm's execution logic typically stops upon the first hook failure, and it does not always perform a retrospective cleanup of previously successful hooks or other pending hooks in the sequence [7]. 3. Recommendation: Because hook-failed may not provide the desired cleanup in all multi-hook scenarios, it is common to use before-hook-creation as a baseline to ensure a "clean slate" for subsequent releases [4][5]. For Job resources specifically, it is often recommended to combine the Helm hook policy with the Kubernetes-native ttlSecondsAfterFinished field in the Job spec to ensure resources are cleaned up regardless of Helm's internal hook state [1][2][5].
Citations:
- 1: https://helm.sh/docs/topics/charts_hooks/
- 2: https://github.com/helm/helm-www/blob/main/docs/topics/charts_hooks.md
- 3: https://github.com/helm/helm/blob/827a960e/pkg/release/v1/hook.go
- 4: https://github.com/helm/helm/blob/9ad53aac42165a5fadc6c87be0dea6b115f93090/docs/charts_hooks.md
- 5: https://kubernetes.recipes/recipes/helm/helm-hook-delete-policy/
- 6: Hook delete policy not honored for preceding resource on a failure helm/helm#3714
- 7: Hook delete policy of "hook-failed" not honored for preceding resource on a failure helm/helm#10279
Reject hook policies that omit before-hook-creation.
If a manifest sets only helm.sh/hook-delete-policy: hook-failed, a successful hook remains and a later helm upgrade can fail with an existing-resource error. Require before-hook-creation or reject and document incompatible policies.
🤖 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/localformat/vendor_wrapper.go` at line 240, Update the
hook annotation handling around annos["helm.sh/hook"] to validate
helm.sh/hook-delete-policy: require before-hook-creation whenever a Helm hook is
configured, and reject policies that omit it, including hook-failed alone.
Document the incompatible policy requirement alongside the validation.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 8 \
'injectPostInstallHooks|stripHelmHooks|writeMixedManifests|localformat\.Write|argocd' \
pkg/bundler/deployerRepository: NVIDIA/aicr
Length of output: 50368
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Examine vendor_wrapper.go around line 240
echo "=== vendor_wrapper.go context around line 240 ==="
sed -n '230,250p' pkg/bundler/deployer/localformat/vendor_wrapper.go
# Check hooks.go for documentation
echo -e "\n=== hooks.go content ==="
cat pkg/bundler/deployer/localformat/hooks.go
# Search for annotation stripping in localformat
echo -e "\n=== stripping logic in localformat ==="
rg -n 'helm\.sh/hook|stripHelmHooks|annotation' pkg/bundler/deployer/localformat/ --type go -A 2 -B 2 | head -100Repository: NVIDIA/aicr
Length of output: 15391
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find all calls to stripHelmHooks
echo "=== stripHelmHooks invocations ==="
rg -n 'stripHelmHooks' pkg/bundler/deployer/localformat/ --type go
# Also check the writer.go to see the full write flow
echo -e "\n=== writer.go key sections ==="
rg -n -B3 -A5 'stripHelmHooks|writeMixedManifests' pkg/bundler/deployer/localformat/writer.goRepository: NVIDIA/aicr
Length of output: 1586
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Examine local_helm.go around line 168
echo "=== local_helm.go context around line 168 ==="
sed -n '150,180p' pkg/bundler/deployer/localformat/local_helm.go
# Get a broader context
echo -e "\n=== local_helm.go function that calls stripHelmHooks ==="
sed -n '100,200p' pkg/bundler/deployer/localformat/local_helm.go | head -100Repository: NVIDIA/aicr
Length of output: 5784
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find where vendor_wrapper is used
echo "=== vendor_wrapper usage ==="
rg -n 'vendor_wrapper\|injectPostInstallHooks' pkg/bundler/deployer/localformat/ --type go -B 2 -A 2 | head -50
# Check the folder types to understand when injectPostInstallHooks is called
echo -e "\n=== Folder kinds and folder creation ==="
rg -n 'KindLocalHelm|KindUpstreamHelm|injectPostInstallHooks' pkg/bundler/deployer/localformat/folder.go --type go -A 3 -B 1Repository: NVIDIA/aicr
Length of output: 178
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Search all files for vendor_wrapper
echo "=== vendor_wrapper file references ==="
rg -n 'vendor_wrapper' pkg/bundler/deployer/ --type go
# Check what file vendor_wrapper.go is in
echo -e "\n=== vendor_wrapper.go location ==="
find pkg/bundler/deployer -name '*vendor*'
# Read vendor_wrapper.go more broadly to understand its context
echo -e "\n=== vendor_wrapper.go beginning ==="
head -100 pkg/bundler/deployer/localformat/vendor_wrapper.goRepository: NVIDIA/aicr
Length of output: 188
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# List files in localformat directory
echo "=== Files in localformat ==="
ls -la pkg/bundler/deployer/localformat/
# Search for the annotation that's mentioned in the review
echo -e "\n=== Files containing helm.sh/hook annotations ==="
rg -l 'helm.sh/hook' pkg/bundler/deployer/localformat/
# Search more broadly
echo -e "\n=== Files containing post-install,post-upgrade ==="
rg -n 'post-install,post-upgrade' pkg/bundler/deployer/localformat/ --type goRepository: NVIDIA/aicr
Length of output: 3666
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check vendor.go and vendor_folder.go for hook stripping
echo "=== vendor.go references to hooks or stripping ==="
rg -n 'stripHelmHooks|helm\.sh/hook' pkg/bundler/deployer/localformat/vendor.go --type go -A 2 -B 2
# Check vendor_folder.go
echo -e "\n=== vendor_folder.go references to hooks or stripping ==="
rg -n 'stripHelmHooks|helm\.sh/hook' pkg/bundler/deployer/localformat/vendor_folder.go --type go -A 2 -B 2
# Check vendor_write_test.go context around line 172 where hooks are mentioned
echo -e "\n=== vendor_write_test.go context around post-install,post-upgrade ==="
sed -n '160,190p' pkg/bundler/deployer/localformat/vendor_write_test.goRepository: NVIDIA/aicr
Length of output: 200
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Look for the function that processes vendored charts
echo "=== vendor_wrapper.go function definition and context ==="
sed -n '1,100p' pkg/bundler/deployer/localformat/vendor_wrapper.go
# Check what calls injectPostInstallHooks
echo -e "\n=== Search for injectPostInstallHooks calls ==="
rg -n 'injectPostInstallHooks' pkg/bundler/deployer/localformat/ --type go -B 3 -A 3Repository: NVIDIA/aicr
Length of output: 11611
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Check if vendored charts go through hook stripping
echo "=== vendor_folder.go full processing after injectPostInstallHooks ==="
sed -n '280,320p' pkg/bundler/deployer/localformat/vendor_folder.go
# Check how argocd deployer handles vendored folders
echo -e "\n=== argocd deployer vendor handling ==="
rg -n 'vendor|KindVendored' pkg/bundler/deployer/argocd/ --type go -B 2 -A 2 | head -100
# Check if there's KindVendored in folder types
echo -e "\n=== Folder kinds defined ==="
rg -n 'Kind[A-Z]' pkg/bundler/deployer/localformat/folder.go --type goRepository: NVIDIA/aicr
Length of output: 5447
Hook annotations remain in vendored mixed-component bundles passed to Argo CD.
At line 285 in vendor_folder.go, injectPostInstallHooks() adds helm.sh/hook: post-install,post-upgrade to recipe-side manifests to order them after the vendored Helm subchart. However, unlike the path in local_helm.go (which calls stripHelmHooks() after rendering), vendored mixed components never strip these annotations before the folder reaches downstream deployers.
When Argo CD consumes the bundle, it maps helm.sh/hook: post-install,post-upgrade to argocd.argoproj.io/hook: PostSync. With syncPolicy.automated, Argo CD only fires PostSync hooks when sync resources are out-of-sync. A chart containing only hook-annotated resources appears trivially "Synced" and the recipe-side manifests are silently never applied.
Add stripHelmHooks() after the injectPostInstallHooks() call in vendor_folder.go (around line 285) to prevent this data loss in Argo CD deployments. Stripping is safe because folder-level NNN ordering at the bundle layer already subsumes the role these hooks play.
🤖 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/localformat/vendor_wrapper.go` at line 240, Update the
vendored mixed-component flow in vendor_folder.go to call stripHelmHooks()
immediately after injectPostInstallHooks(), ensuring hook annotations are
removed before the bundle is passed downstream while preserving the existing
folder-level ordering.
mchmarny
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES — 1 blocker, 1 non-blocking.
Validated at 0920e5a by building aicr at head, generating a real --vendor-charts bundle for the h100-eks-inference recipe, and inspecting the emitted templates/. go test ./pkg/bundler/deployer/localformat/... passes.
CI is green but is not evidence for this change: the only --vendor-charts e2e (tests/chainsaw/cli/bundle-vendor-charts) bundles and file-inspects, and never runs a second helm upgrade — which is exactly the path this PR newly activates.
The blocker is the interaction with the helm.sh/hook-delete-policy: before-hook-creation that the same function stamps: adding post-upgrade turns each upgrade into a delete-then-recreate, which for the hookless CRD and Namespace manifests means cascading deletion of user data. Details inline.
On @coderabbitai's delete-policy thread: confirmed as a real defect rather than a verification ask, so raising the severity accordingly.
| return false | ||
| } | ||
| annos["helm.sh/hook"] = "post-install" | ||
| annos["helm.sh/hook"] = "post-install,post-upgrade" |
There was a problem hiding this comment.
Blocking — data loss on helm upgrade for cascade-delete kinds.
This function still stamps helm.sh/hook-delete-policy: before-hook-creation a few lines down (L246-247). Adding post-upgrade therefore doesn't "re-apply" the manifest — it makes Helm delete then recreate it on every upgrade. docs/user/component-catalog.md:37 already documents that exact semantic for the Kueue quota CRs; this change extends it to every hookless recipe-side manifest, including kinds whose deletion cascades.
Reproduced at this head — aicr bundle -r <h100-eks-inference> --vendor-charts emits:
# 001-agentgateway-crds/templates/gateway-api-crds.yaml
kind: CustomResourceDefinition # gatewayclasses, gateways, grpcroutes, httproutes, referencegrants
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-delete-policy: before-hook-creation001-agentgateway-crds/install.sh runs helm upgrade --install agentgateway-crds ./, so a second ./deploy.sh deletes those five Gateway API CRDs; the apiserver garbage-collects every user-authored Gateway/HTTPRoute/GRPCRoute/InferencePool, and the CRDs are recreated empty. Not recoverable. Same shape for talos-namespace.yaml (kind: Namespace, cascades to everything in it) and compute-domain.yaml. These are hookless because TestManifestHelmHooksRequired only requires hooks for custom apiVersions.
CI can't catch this: tests/chainsaw/cli/bundle-vendor-charts inspects the emitted files but never performs a second helm upgrade.
There's also no way for an author to opt out via the delete-policy escape at L243-247 — Helm parses only before-hook-creation/hook-succeeded/hook-failed and defaults to before-hook-creation when nothing matches, so a value like keep is silently ignored.
Minimum correction: keep post-install only for kinds whose deletion cascades (CustomResourceDefinition, Namespace), injecting post-install,post-upgrade for the rest — plus a regression test asserting a CRD doc and a Namespace doc do not come back with post-upgrade alongside before-hook-creation.
There was a problem hiding this comment.
Thanks — agreed. Dropped the post-upgrade + before-hook-creation approach.
This PR now takes Option B / structural fix (#1835): vendored mixed components emit a tracked <component>-post Helm release (same as non-vendored) instead of injecting helm.sh/hook resources. Upgrades three-way-merge in place; uninstall removes the resources; no delete-then-recreate on CRD/Namespace kinds.
Regression coverage: TestWrite_VendorCharts_MixedCascadeDeleteKinds (hookless CRD, author-hooked CRD, Namespace). See 0d86236c.
| > declares a `post-upgrade` hook itself) and are left behind by | ||
| > `helm uninstall`. Remove them manually after uninstalling a vendored bundle | ||
| > post-install,post-upgrade` resources. They apply on install and are | ||
| > re-applied on `helm upgrade`, but Helm does not track hook resources as |
There was a problem hiding this comment.
Non-blocking: "re-applied on helm upgrade" reads as an in-place apply, but with the injected helm.sh/hook-delete-policy: before-hook-creation it's a delete followed by a recreate. Worth stating explicitly and mirroring the operator warning the Kueue entry already carries in docs/user/component-catalog.md ("quiesce before upgrading… upgrades reset to shipped defaults"), so operators know an upgrade churns the resource rather than patching it.
There was a problem hiding this comment.
Docs rewritten for the structural fix: no longer document hook re-apply / delete-recreate as the supported vendored path. Author-declared hooks on recipe manifests are stripped into ordinary -post templates (same as non-vendored). Broken #kueue anchor removed with that section.
njhensley
left a comment
There was a problem hiding this comment.
📋 Multi-persona review — head 0920e5a
▎ Method: 4 persona passes (Correctness, Domain & Architecture, Docs, Test-coverage), each finding independently confirmed or refuted by a senior meta-reviewer against the resolved code. Line links pinned to head 0920e5a.
▎ Tier legend: 🔴 Blocker · 🟠 Major · 🟡 Minor · 🔵 Nitpick · ✅ Confirmed non-issue
⚠️ @mchmarny already filed CHANGES_REQUESTED on this PR. My 🔴 blocker is the same defect, independently re-derived from the code — I credit it rather than claim it. My additive signal over the existing reviews is narrow: thekeep-comment defect (🟡), the misleading Go doc-comments this PR added (🟡), the tracked-vs-untracked lifecycle divergence (🟡), and two refutations of CodeRabbit findings (below). The blocker itself is corroboration, and I widen its blast radius to CustomResourceDefinitions (agentgateway-crdsis a mixed component, so its CRD manifests get the same annotations).
Overall assessment — Comment (defer to @mchmarny's standing Request-changes)
Adding post-upgrade correctly makes helm upgrade re-fire the hook (fixing #1835's stale DaemonSet). But the same function also stamps helm.sh/hook-delete-policy: before-hook-creation, so re-firing is a delete-then-recreate, and injection is kind-blind — for the hookless cascade-delete manifests on the --vendor-charts path (agentgateway-crds CRDs, talos-namespace Namespace, slinky compute-domain CR) every ./deploy.sh re-run cascade-deletes user data. That's the blocker. Everything else is doc/comment/test polish subordinate to fixing it.
Inline findings follow. One finding can't be inline (its file isn't in this diff):
🟡 Minor — the --vendor-charts e2e never runs a second helm upgrade. tests/chainsaw/cli/bundle-vendor-charts/chainsaw-test.yaml uses a fake helm (version/pull only), never installs, never upgrades — verification is a static grep of emitted annotations. The behavior this PR fixes has zero execution-level coverage, which is why the blocker passed green CI. Acceptable as a hermetic bundling test, but note the blind spot; ideally add a KWOK/kind lane that installs then upgrades a vendored mixed bundle and asserts re-apply (and non-destruction of a CRD/Namespace variant).
✅ Confirmed non-issues (checked and cleared)
- CodeRabbit — "
leaves them behind by helm uninstall" is obsolete: REFUTED. That sentence is in the--vendor-chartsblock, which injects hooks and does not callstripHelmHooks. Injected hook resources genuinely aren't tracked as release members and do survivehelm uninstall, so the statement is correct. CodeRabbit conflated it with the non-vendored (stripped)local_helm.gopath. - CodeRabbit — Argo CD "PostSync never fires" for vendored mixed: REFUTED / out of scope. The vendored folder is consumed by the localformat helm
install.sh, not Argo CD; the wrapper always carries the subchart's real (non-hook) resources so a sync fires; andpost-installalready mapped to PostSync pre-PR, so addingpost-upgradeintroduces no new Argo behavior. - Delete-policy stamping branches are covered —
TestInjectPostInstallHooks_AddsAnnotations/_HonorsAuthorDeletePolicy/_PreservesAuthorHook. The gap is the cascade-kind/upgrade interaction, not the branches. docs/user/cli-reference.mdchange (post-install→post-install,post-upgrade) is accurate.
Summary
| Tier | Count | Items |
|---|---|---|
| 🔴 Blocker | 1 | delete-then-recreate cascade data loss on upgrade (CRD/Namespace/CR) — same as @mchmarny |
| 🟠 Major | 0 | — |
| 🟡 Minor | 6 | invalid keep escape-hatch comment · godoc "re-apply" wording · bundling.md churn warning · missing cascade-kind test · e2e no-upgrade gap · hook-vs-tracked lifecycle divergence |
| 🔵 Nitpick | 1 | rename injectPostInstallHooks |
Recommendation: the fix is kind-aware injection (skip post-upgrade/before-hook-creation for cascade-owning kinds) plus a regression test; the doc/comment minors then fall out naturally. Posting as a Comment since @mchmarny's Request-changes already gates the merge.
| return false | ||
| } | ||
| annos["helm.sh/hook"] = "post-install" | ||
| annos["helm.sh/hook"] = "post-install,post-upgrade" |
There was a problem hiding this comment.
🔴 Blocker — post-install,post-upgrade + before-hook-creation deletes-then-recreates recipe-side manifests on every helm upgrade; cascades to data loss for CRD/Namespace kinds
This line sets helm.sh/hook: post-install,post-upgrade, and L246-247 also stamps helm.sh/hook-delete-policy: before-hook-creation on every hookless manifest. vendor_folder.go:285 applies this kind-blind to all --vendor-charts mixed-component manifests (NOT stripped, unlike the non-vendored path at local_helm.go:168). install.sh deploys via helm upgrade --install, so adding post-upgrade fires the hook on every upgrade and before-hook-creation deletes the existing resource before recreating it. Pre-PR (post-install only) the hook never fired on upgrade, so this destructive path is newly introduced. This is the same defect @mchmarny flagged, independently re-derived.
Blast radius: agentgateway-crds is a mixed component (helm chart oci://cr.agentgateway.dev/charts + gateway-api-crds.yaml/inference-extension-crds.yaml, wired in recipes/mixins/platform-inference.yaml) — deleting a CustomResourceDefinition GCs every Gateway/HTTPRoute/GRPCRoute/InferencePool cluster-wide. network-operator/manifests/talos-namespace.yaml (Namespace) cascades to all contents; slinky-slurm/manifests/compute-domain.yaml tears down the IMEX domain. Not recoverable.
Fix: Make injection kind-aware: for cascade-owning/cluster-scoped kinds (CustomResourceDefinition, Namespace, and arguably CRs/PVCs) keep post-install only, drop before-hook-creation, or emit them as ordinary wrapper-chart templates ordered by Helm's kind InstallOrder so upgrades patch in place. Ship with a regression test asserting a CRD and a Namespace doc do NOT get post-upgrade alongside before-hook-creation.
There was a problem hiding this comment.
Thanks and agreed. Dropped the post-upgrade + before-hook-creation approach.
This PR now takes Option B / structural fix (#1835): vendored mixed components emit a tracked <component>-post Helm release (same as non-vendored) instead of injecting helm.sh/hook resources. Upgrades three-way-merge in place; uninstall removes the resources; no delete-then-recreate on CRD/Namespace kinds.
Regression coverage: TestWrite_VendorCharts_MixedCascadeDeleteKinds (hookless CRD, author-hooked CRD, Namespace). See 0d86236c.
| annos["helm.sh/hook"] = "post-install" | ||
| annos["helm.sh/hook"] = "post-install,post-upgrade" | ||
| annos["helm.sh/hook-weight"] = strconv.Itoa(weight) | ||
| // Honor an author-declared delete-policy for the same reason we |
There was a problem hiding this comment.
🟡 Minor — Comment documents keep as a helm.sh/hook-delete-policy escape hatch, but keep is not a valid value for that annotation
The comment here (through L245) tells authors they can pre-set helm.sh/hook-delete-policy: keep to preserve install-time state across upgrades. But keep is not a valid hook-delete-policy value (valid: before-hook-creation, hook-succeeded, hook-failed); it is the value of a DIFFERENT annotation, helm.sh/resource-policy. Helm ignores the unrecognized value and defaults to before-hook-creation, so the documented opt-out does nothing. (Pre-existing comment, but it now sits next to the newly-added upgrade semantics.)
Blast radius: An author following the comment to protect a stateful manifest gets silent delete-recreate anyway. The real opt-out is declaring helm.sh/hook explicitly (the L235 alreadyHooked short-circuit), which the comment doesn't mention.
Fix: Drop the keep reference, or redirect to helm.sh/resource-policy: keep on a non-hook template; mention the working author-set-helm.sh/hook opt-out.
There was a problem hiding this comment.
N/A after Option B — injectPostInstallHooks / related helpers and comments were deleted rather than renamed or reworded.
| // Why both phases: a post-install-only hook fires on the initial | ||
| // install but Helm skips it on subsequent `helm upgrade` runs, so a | ||
| // version bump on the recipe-side manifest never reaches the cluster. | ||
| // Adding post-upgrade makes upgrades re-apply the manifest. Uninstall |
There was a problem hiding this comment.
🟡 Minor — godoc/header say upgrades "re-apply" the manifest — actually delete-then-recreate
The header comment (L32-33) and this injectPostInstallHooks godoc block, both edited by this PR, describe the upgrade as apply/"re-apply the manifest" with no mention that before-hook-creation (L246-247) makes each upgrade a destructive delete-then-recreate. Not raised by the other reviewers (their wording note was about the user docs, not these Go comments).
Blast radius: Maintainers reading these godocs to reason about hook semantics under-estimate the upgrade blast radius (transient teardown, owned-object cascade).
Fix: State explicitly that, because delete-policy is before-hook-creation, each upgrade deletes and recreates the resource; cross-reference the operator churn warning.
There was a problem hiding this comment.
N/A after Option B — injectPostInstallHooks / related helpers and comments were deleted rather than renamed or reworded.
| > release: they are not re-applied on `helm upgrade` (unless the manifest | ||
| > declares a `post-upgrade` hook itself) and are left behind by | ||
| > `helm uninstall`. Remove them manually after uninstalling a vendored bundle | ||
| > post-install,post-upgrade` resources. They apply on install and are |
There was a problem hiding this comment.
🟡 Minor — bundling.md "re-applied on helm upgrade" hides destructive delete-then-recreate churn/reset
The changed note says manifests apply on install and are 're-applied on helm upgrade', omitting that the injected before-hook-creation delete policy tears the resource down and resets it to shipped defaults on every upgrade. The repo's own component-catalog.md Kueue entry documents this identical mechanism correctly (quiesce before upgrading, upgrades reset to shipped defaults). (Echoes @mchmarny's non-blocking note.)
Blast radius: Operators get no warning to quiesce/drain before upgrading and no notice that hand-tuned state is reset; inconsistent with the project's established phrasing for the same behavior.
Fix: Mirror the Kueue warning: re-created (delete-then-recreate) on every helm upgrade, transient teardown of the resource, post-install drift reset to the shipped manifest.
There was a problem hiding this comment.
Docs rewritten for the structural fix: no longer document hook re-apply / delete-recreate as the supported vendored path. Author-declared hooks on recipe manifests are stripped into ordinary -post templates (same as non-vendored). Broken #kueue anchor removed with that section.
| t.Errorf("hook = %v, want post-install", annos["helm.sh/hook"]) | ||
| // Both phases: post-install for the initial deploy AND post-upgrade | ||
| // so `helm upgrade` re-applies the recipe-side manifest. A single | ||
| // post-install phase leaves the manifest stale across upgrades |
There was a problem hiding this comment.
🟡 Minor — No regression test for cascade-delete kinds (CRD/Namespace) through the hook-injection path
This assertion (and every test driving injectHookOnDoc: TestInjectPostInstallHooks_*, TestWrite_VendorCharts_Mixed) uses only ConfigMap/ClusterRole — neither cascades. Namespace manifests elsewhere in the suite flow through the stripped pre-manifest path, never injectHookOnDoc. The PR only flips expected strings from post-install to post-install,post-upgrade; nothing pins the intended (safe) treatment of a CRD/Namespace routed through injection.
Blast radius: The exact real-world manifests this fix targets have no test guarding against the blocker's data-loss path. Any kind-aware fix MUST ship with such a test.
Fix: Add a table-driven test feeding a CRD and a Namespace doc through injectPostInstallHooks and asserting the delete-policy/hook phase differs from the ConfigMap case (or, if uniform is intentional, pin that as a conscious contract).
There was a problem hiding this comment.
Added TestWrite_VendorCharts_MixedCascadeDeleteKinds covering CRD (hookless + author-hooked) and Namespace through the vendored mixed path; asserts no helm.sh/hook / before-hook-creation.
| @@ -132,10 +135,19 @@ func InjectPostInstallHooks(in []byte) ([]byte, error) { | |||
| } | |||
|
|
|||
| // injectPostInstallHooks rewrites a multi-document YAML stream to add | |||
There was a problem hiding this comment.
🟡 Minor — Vendored path uses untracked Helm hooks where the non-vendored path deploys tracked release members; divergence widened
Non-vendored (local_helm.go:168 stripHelmHooks) makes recipe-side manifests ordinary members of the <component>-post release (three-way-merge patch on upgrade, deleted on uninstall). Vendored makes them Helm hooks: not tracked as release members, survive helm uninstall, and only upgrade-repeatable via before-hook-creation (delete-recreate). This PR widens the divergence — the uninstall-leaking residue is now re-created on every upgrade, not once. (Not raised by the other reviewers.)
Blast radius: Operational surprise across all vendored-mixed components: orphaned hook resources after uninstall + per-upgrade churn.
Fix: Prefer emitting recipe-side manifests as regular wrapper-chart templates ordered by Helm kind InstallOrder so the vendored path matches the non-vendored tracked lifecycle; or wire the manual uninstall-cleanup path into undeploy.sh.
There was a problem hiding this comment.
Agreed — this is the path taken. Vendored and non-vendored now share the tracked -post release shape; hook injection helpers are removed.
| @@ -132,10 +135,19 @@ func InjectPostInstallHooks(in []byte) ([]byte, error) { | |||
| } | |||
|
|
|||
| // injectPostInstallHooks rewrites a multi-document YAML stream to add | |||
There was a problem hiding this comment.
🔵 Nitpick — Rename injectPostInstallHooks / InjectPostInstallHooks — it now injects post-upgrade too
The helper injects post-install AND post-upgrade; the PostInstall name is stale. (Also raised by CodeRabbit.)
Blast radius: Reader confusion only.
Fix: Rename to a lifecycle-neutral name (e.g. injectPostLifecycleHooks) and the TestInjectPostInstallHooks_* tests to match. Optional / defer.
There was a problem hiding this comment.
N/A after Option B — injectPostInstallHooks / related helpers and comments were deleted rather than renamed or reworded.
Reviewers of #2061 (the prior code-change form of this PR) identified that a naive 'add post-upgrade to the hook' fix regresses behavior: combined with the injected 'helm.sh/hook-delete-policy: before-hook-creation', firing a post-upgrade hook deletes and recreates the resource on every 'helm upgrade' — cascade-destructive for CRDs, Namespaces, and any operator-tuned state. The Kueue component already documents this exact pattern for its quota CRs and instructs operators to quiesce before upgrading. The correct fix (mirror the non-vendored '<component>-post' release shape for --vendor-charts, so recipe-side manifests become tracked release members instead of Helm hooks) is a larger structural change that touches all deployers (helm, helmfile, argocd, argocd-helm, flux) and is left as follow-up work referenced in the trade-off note. This PR instead documents the current vendored-path limitations honestly so operators can make an informed choice: - Upgrade drift: post-install-only hooks skip 'helm upgrade' - Uninstall residue: hook resources survive 'helm uninstall' - Argo CD PostSync mapping: under syncPolicy.automated, chart appears trivially Synced and the hook never fires — manifests silently never applied. Documented in the stripHelmHooks godoc in pkg/bundler/deployer/localformat/hooks.go and now surfaced to operators here. Also calls out the destructive nature of the before-hook-creation delete-policy for stateful kinds, cross-links the Kueue precedent, and points operators at the non-vendored path as the workaround until the structural fix lands. Fixes #1835 (documentation portion — leaves the structural fix as follow-up work per the reviewer feedback on #2061) Signed-off-by: Rohit Rajani <[email protected]>
0920e5a to
bbc841d
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
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 `@docs/user/bundling.md`:
- Around line 155-189: Update the lifecycle description around the vendored hook
resources to reflect both helm.sh/hook phases, post-install and post-upgrade.
Replace the upgrade-drift and hypothetical post-upgrade wording with the
behavior that helm upgrade fires the hook and before-hook-creation deletes and
recreates the resource; retain the manual helm uninstall cleanup instructions
and adjust the follow-up wording to match the new lifecycle.
🪄 Autofix
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: cf14cf03-92f6-4dd5-b84b-db4c5fb4d191
📒 Files selected for processing (1)
docs/user/bundling.md
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/user/bundling.md (1)
156-189:⚠️ Potential issue | 🟠 MajorSynchronize the lifecycle text with the
post-upgradehook.The supplied manifest
recipes/components/network-operator/manifests/nfd-network-rule.yaml:31-58declareshelm.sh/hook: post-install,post-upgrade, but this paragraph still documentspost-installonly. TheUpgrade driftbullet is therefore false,post-upgradeis incorrectly described as hypothetical, and issue#1835is incorrectly retained as future work.Update the Argo CD text for the combined annotation. Describe
helm upgradeas a delete-then-recreate operation because ofbefore-hook-creation. Adjust “all three limitations” to match the remaining limitations. Keep the manualhelm uninstallcleanup guidance.Proposed documentation changes
- post-install + post-install,post-upgrade - **Upgrade drift.** A `post-install`-only hook does not fire on `helm upgrade`... + **Upgrade recreation.** `post-upgrade` fires on `helm upgrade`, and + `before-hook-creation` deletes and recreates the resource first... - a hypothetical future `post-upgrade` variant + `helm upgrade` - Mirroring ... is tracked as follow-up work; see issue `#1835`. + [remove this obsolete follow-up statement]Verification:
#!/bin/bash set -euo pipefail sed -n '153,189p' docs/user/bundling.md printf '%s\n' '--- hook annotations ---' rg -n -C 2 'helm.sh/hook:' recipes/components printf '%s\n' '--- issue reference ---' rg -n '1835|post-install|post-upgrade' docs/user/bundling.md🤖 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 `@docs/user/bundling.md` around lines 156 - 189, Update the vendored lifecycle documentation around the hook limitations to reflect the combined helm.sh/hook post-install,post-upgrade annotation: remove the false upgrade-drift limitation, describe helm upgrade as deleting and recreating resources due to before-hook-creation, and update the Argo CD mapping accordingly. Retain the manual helm uninstall cleanup guidance, revise the limitation count and concluding text to cover only the remaining issues, and remove the obsolete issue `#1835` follow-up reference.
🤖 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.
Duplicate comments:
In `@docs/user/bundling.md`:
- Around line 156-189: Update the vendored lifecycle documentation around the
hook limitations to reflect the combined helm.sh/hook post-install,post-upgrade
annotation: remove the false upgrade-drift limitation, describe helm upgrade as
deleting and recreating resources due to before-hook-creation, and update the
Argo CD mapping accordingly. Retain the manual helm uninstall cleanup guidance,
revise the limitation count and concluding text to cover only the remaining
issues, and remove the obsolete issue `#1835` follow-up reference.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 9606d4ef-f5b3-48b7-90cb-7982f3b1e44d
📒 Files selected for processing (1)
docs/user/bundling.md
mchmarny
left a comment
There was a problem hiding this comment.
COMMENT — 3 blockers, 2 non-blocking.
Re-reviewed at head eb1bb22. The PR is now docs-only (three-dot diff vs main is docs/user/bundling.md, +34/-8); the Go change that drew my earlier CHANGES_REQUESTED is gone, so that blocker is resolved by removal. Every finding from the prior round on vendor_wrapper.go is moot.
Validated by reading the code the paragraph describes, not the diff alone: injectHookOnDoc's alreadyHooked short-circuit, stripHelmHooks's single caller (local_helm.go:168, non-vendored only, so the Argo CD bullet is accurate and reachable), and go test -run TestInjectPostInstallHooks ./pkg/bundler/deployer/localformat/ (8/8 pass). CI is green but is not evidence for this change: no check validates a doc statement against the annotations actually emitted, and lychee runs --offline without --include-fragments.
Two blockers are inline. The third has no changed-line anchor:
Blocking - Fixes #1835 will auto-close an issue this PR explicitly defers. #1835 is open, and the text this PR adds says the structural fix is "tracked as follow-up work; see issue #1835" (L189). Merging as written ships a doc pointing readers at an issue the same merge closes. Change the PR body to Related: #1835.
Non-blocking - stale title and body. The title is still fix(bundler): re-apply vendored mixed-component manifests on helm upg… for a change that no longer touches pkg/bundler; it lands verbatim in the squash commit and the generated changelog. Suggest docs(bundling): document vendored mixed-component hook limitations. The body is the previous code-change commit message followed by an unfilled template.
Separately: mergeStateStatus is BEHIND (main is at b52aefb), and my earlier CHANGES_REQUESTED still gates merge. I will clear it once the above is addressed.
CodeRabbit's Aug 10 comment overlaps the two inline blockers. Its stated rationale conflates the PR objective with the removed code change, but its observation about nfd-network-rule.yaml is correct.
| > rather than tracked release members, this shape carries three operator-facing | ||
| > limitations that the default (non-vendored) path does not have: | ||
| > | ||
| > - **Upgrade drift.** A `post-install`-only hook does not fire on |
There was a problem hiding this comment.
Blocking - this bullet drops the accuracy carve-out the previous text carried, and its own named example contradicts it.
The sentence this replaces read "not re-applied on helm upgrade (unless the manifest declares a post-upgrade hook itself)". Without that carve-out the bullet is false for most shipped manifests: injectHookOnDoc short-circuits on alreadyHooked and leaves author-declared hooks untouched (vendor_wrapper.go#L223-L226), pinned by TestInjectPostInstallHooks_PreservesAuthorHook.
Of the 45 manifests under recipes/components/*/manifests/, 27 declare their own hook and 21 declare post-install,post-upgrade. That includes this paragraph's first example, the network-operator NicClusterPolicy at recipes/components/network-operator/manifests/nic-cluster-policy-aks.yaml:37, which does fire on helm upgrade. Only the second example (nvidia-peermem-reloader.yaml) is hookless and actually exhibits the drift, so the two manifests named side by side, both from the AKS network-operator component, behave oppositely.
Minimum fix: restore the "unless the manifest declares a post-upgrade hook itself" qualifier and scope the bullet to hookless manifests.
There was a problem hiding this comment.
Thanks — agreed. Dropped the post-upgrade + before-hook-creation approach.
This PR now takes Option B / structural fix (#1835): vendored mixed components emit a tracked <component>-post Helm release (same as non-vendored) instead of injecting helm.sh/hook resources. Upgrades three-way-merge in place; uninstall removes the resources; no delete-then-recreate on CRD/Namespace kinds.
Regression coverage: TestWrite_VendorCharts_MixedCascadeDeleteKinds (hookless CRD, author-hooked CRD, Namespace). See 0d86236c.
| > fires — recipe-side manifests are silently never applied. | ||
| > | ||
| > Note that `helm.sh/hook-delete-policy: before-hook-creation` also means any | ||
| > firing of the hook (e.g., re-installing the bundle or a hypothetical future |
There was a problem hiding this comment.
Blocking - post-upgrade delete-then-recreate is live today, not hypothetical.
These manifests already ship helm.sh/hook: post-install,post-upgrade plus helm.sh/hook-delete-policy: before-hook-creation, and pass through the vendored templates/ unmodified:
recipes/components/kueue/manifests/resource-flavor.yaml:36-38(alsocluster-queue.yaml,local-queue.yaml)recipes/components/agentgateway/manifests/inference-gateway.yaml:32-34recipes/components/kubeflow-trainer/manifests/torch-distributed-cluster-training-runtime.yaml:22-24
helm upgrade deletes and recreates them on every run right now. docs/user/component-catalog.md:37 documents exactly that for the Kueue quota CRs ("quiesce queues before upgrading ... upgrades reset them to the shipped defaults"), so as written this page tells operators the opposite of the catalog, and withholds the quiesce warning from precisely the operators who need it.
Minimum fix: describe the delete-then-recreate as current behavior for author-hooked manifests and cross-link the Kueue quiesce guidance, instead of framing it as a future variant.
There was a problem hiding this comment.
Thanks — agreed. Dropped the post-upgrade + before-hook-creation approach.
This PR now takes Option B / structural fix (#1835): vendored mixed components emit a tracked <component>-post Helm release (same as non-vendored) instead of injecting helm.sh/hook resources. Upgrades three-way-merge in place; uninstall removes the resources; no delete-then-recreate on CRD/Namespace kinds.
Regression coverage: TestWrite_VendorCharts_MixedCascadeDeleteKinds (hookless CRD, author-hooked CRD, Namespace). See 0d86236c.
| > stateful or ownership-bearing kinds (CRDs whose deletion cascades to CRs, | ||
| > Namespaces with owned objects, resources with operator-tuned state) this is | ||
| > destructive; the Kueue component | ||
| > [documents this exact pattern](component-catalog.md#kueue) and instructs |
There was a problem hiding this comment.
Non-blocking - broken anchor. component-catalog.md#kueue does not resolve: there is no Kueue heading in that file, the content is a table row at docs/user/component-catalog.md:37. GitHub and Fern generate anchors from headings only, so the link lands at the top of the page. CI will not catch it, since lychee runs --offline without --include-fragments. Suggest linking to component-catalog.md#components and naming the row in prose.
There was a problem hiding this comment.
Docs rewritten for the structural fix: no longer document hook re-apply / delete-recreate as the supported vendored path. Author-declared hooks on recipe manifests are stripped into ordinary -post templates (same as non-vendored). Broken #kueue anchor removed with that section.
Replace helm.sh/hook injection under --vendor-charts with the same <component>-post release the non-vendored path already uses. That closes upgrade drift, uninstall residue, and Argo CD PostSync silent-drop without the delete-then-recreate hazard of adding post-upgrade to before-hook-creation hooks (reviewers of #2061). Fixes #1835 Signed-off-by: Rohit Rajani <[email protected]>
eb1bb22 to
0d86236
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
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/localformat/writer.go (1)
274-291: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick winCheck cancellation during folder counting.
A canceled
Writecall can scan every component before this loop returns. Checkctx.Err()in this loop and returnErrCodeCanceledfor explicit cancellation.As per coding guidelines, “Always check
ctx.Done()in loops and long-running operations.” Based on learnings, explicit cancellation must useerrors.ErrCodeCanceled.🤖 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/localformat/writer.go` around lines 274 - 291, Update the component-counting loop in Write to check ctx.Err() on each iteration and immediately return errors.ErrCodeCanceled when cancellation is explicit. Preserve the existing folder-counting logic for non-canceled components and use the established Write return shape.Sources: Coding guidelines, Learnings
🤖 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/localformat/writer.go`:
- Around line 446-457: Reject any post-phase Namespace manifest whose name
matches Component.Namespace before appending the folder in the phasePost flow
around injectAuxiliaryFolder. Require that namespace declaration to be emitted
in the pre phase, or ensure a single release remains its sole owner; preserve
other post manifests. Add a regression test covering vendored mixed components.
---
Outside diff comments:
In `@pkg/bundler/deployer/localformat/writer.go`:
- Around line 274-291: Update the component-counting loop in Write to check
ctx.Err() on each iteration and immediately return errors.ErrCodeCanceled when
cancellation is explicit. Preserve the existing folder-counting logic for
non-canceled components and use the established Write return shape.
🪄 Autofix
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: 5df088b7-4a82-4195-b9d1-f40ad6c1718c
📒 Files selected for processing (12)
docs/user/bundling.mddocs/user/cli-reference.mdpkg/bundler/deployer/helmfile/helmfile_test.gopkg/bundler/deployer/localformat/doc.gopkg/bundler/deployer/localformat/empty_render_test.gopkg/bundler/deployer/localformat/folder.gopkg/bundler/deployer/localformat/vendor_folder.gopkg/bundler/deployer/localformat/vendor_wrapper.gopkg/bundler/deployer/localformat/vendor_wrapper_test.gopkg/bundler/deployer/localformat/vendor_write_test.gopkg/bundler/deployer/localformat/writer.gotests/chainsaw/cli/bundle-vendor-charts/chainsaw-test.yaml
💤 Files with no reviewable changes (1)
- pkg/bundler/deployer/localformat/vendor_wrapper_test.go
| // Post-injection: recipe-side manifests as a tracked -post | ||
| // release installed after the vendored subchart, so manifests | ||
| // referencing the chart's CRDs apply once those CRDs exist. | ||
| if pf, err := opts.injectAuxiliaryFolder(idx, c, phasePost); err != nil { | ||
| return WriteResult{}, err | ||
| } else if pf != nil { | ||
| folders = append(folders, *pf) | ||
| slog.Info("wrote local chart folder", | ||
| "index", idx, "dir", pf.Dir, | ||
| "kind", KindLocalHelm.String(), "parent", c.Name) | ||
| idx++ | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- writer.go structure ---'
ast-grep outline pkg/bundler/deployer/localformat/writer.go
printf '%s\n' '--- relevant symbols and references ---'
rg -n -C 5 'injectAuxiliaryFolder|writeVendoredHelmFolder|folderCount|phasePost|create-namespace|Namespace' pkg/bundler/deployer/localformat pkg
printf '%s\n' '--- focused source ---'
sed -n '220,310p' pkg/bundler/deployer/localformat/writer.go
sed -n '380,475p' pkg/bundler/deployer/localformat/writer.goRepository: NVIDIA/aicr
Length of output: 50368
🏁 Script executed:
#!/bin/bash
set -eu
file=pkg/bundler/deployer/localformat/writer.go
printf '%s\n' '--- writer.go relevant definitions ---'
rg -n -C 8 'func .*Write|injectAuxiliaryFolder|writeVendoredHelmFolder|folderCount|phasePre|phasePost|CreateNamespace|Namespace' "$file"
printf '%s\n' '--- local-format files with CreateNamespace or auxiliary injection ---'
rg -l 'CreateNamespace|injectAuxiliaryFolder|writeVendoredHelmFolder' pkg/bundler/deployer/localformat | sort
printf '%s\n' '--- focused companion source ---'
for f in $(rg -l 'CreateNamespace|injectAuxiliaryFolder|writeVendoredHelmFolder' pkg/bundler/deployer/localformat | sort); do
echo "### $f"
rg -n -C 6 'CreateNamespace|injectAuxiliaryFolder|writeVendoredHelmFolder|Namespace' "$f"
doneRepository: NVIDIA/aicr
Length of output: 50367
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- vendored and auxiliary implementations ---'
sed -n '120,190p' pkg/bundler/deployer/localformat/vendor_folder.go
sed -n '135,245p' pkg/bundler/deployer/localformat/local_helm.go
printf '%s\n' '--- post-manifest tests ---'
sed -n '350,550p' pkg/bundler/deployer/localformat/writer_test.go
printf '%s\n' '--- all post Namespace fixtures/references ---'
rg -n -C 4 'ComponentPostManifests|post.*Namespace|kind: Namespace|Namespace/' \
pkg/bundler/deployer/localformat \
-g '*.go' -g '*.yaml' -g '*.yml' -g '*.tmpl'
printf '%s\n' '--- Helmfile release mapping ---'
sed -n '136,245p' pkg/bundler/deployer/helmfile/releases.goRepository: NVIDIA/aicr
Length of output: 39739
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- vendored post tests ---'
sed -n '120,285p' pkg/bundler/deployer/localformat/vendor_write_test.go
printf '%s\n' '--- vendored pre tests ---'
sed -n '330,430p' pkg/bundler/deployer/localformat/vendor_write_test.go
printf '%s\n' '--- read-only behavioral probe ---'
python3 - <<'PY'
from pathlib import Path
import re
writer = Path("pkg/bundler/deployer/localformat/writer.go").read_text()
vendor = Path("pkg/bundler/deployer/localformat/vendor_folder.go").read_text()
local = Path("pkg/bundler/deployer/localformat/local_helm.go").read_text()
checks = {
"post injection follows vendored primary": re.search(
r"writeVendoredHelmFolder\(.*?injectAuxiliaryFolder\(idx, c, phasePost\)",
writer, re.S,
),
"vendored primary requests namespace creation": re.search(
r"\}\{c\.Name, c\.Namespace, true\}.*?CreateNamespace:\s*true",
vendor, re.S,
),
"auxiliary Namespace disables namespace creation": re.search(
r"effectiveCreateNamespace := createNamespace && !hasNamespaceTemplate",
local,
),
"post release uses component namespace": re.search(
r"Namespace:\s*c\.Namespace",
local,
),
}
for name, match in checks.items():
print(f"{name}: {'yes' if match else 'no'}")
# Model the exact relevant output for a vendored component with a post Namespace.
primary_create_namespace = True
post_contains_namespace = True
post_create_namespace = primary_create_namespace and not post_contains_namespace
print(f"modeled primary --create-namespace: {primary_create_namespace}")
print(f"modeled post --create-namespace: {post_create_namespace}")
print("modeled namespace ownership collision: "
f"{primary_create_namespace and post_contains_namespace and not post_create_namespace}")
PYRepository: NVIDIA/aicr
Length of output: 11865
Reject a post-phase Namespace that matches the component namespace.
The vendored primary creates Component.Namespace with --create-namespace. The post release disables that flag when it contains a Namespace, but Helm still rejects the post release when it tries to adopt the existing namespace with ownership metadata from another release.
Reject Namespace/{{ .Component.Namespace }} in post manifests. Require the namespace declaration in the pre phase, or use one release as the sole namespace owner. Add a regression test for vendored mixed components.
🤖 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/localformat/writer.go` around lines 446 - 457, Reject
any post-phase Namespace manifest whose name matches Component.Namespace before
appending the folder in the phasePost flow around injectAuxiliaryFolder. Require
that namespace declaration to be emitted in the pre phase, or ensure a single
release remains its sole owner; preserve other post manifests. Add a regression
test covering vendored mixed components.
Replace helm.sh/hook injection under --vendor-charts with the same <component>-post release the non-vendored path already uses. That closes upgrade drift, uninstall residue, and Argo CD PostSync silent-drop without the delete-then-recreate hazard of adding post-upgrade to before-hook-creation hooks (reviewers of #2061). Fixes #1835 Signed-off-by: Rohit Rajani <[email protected]>
0d86236 to
ddf4c6d
Compare
mchmarny
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES — 1 blocker, 2 non-blocking.
Re-reviewed at head c412628e (previous round was eb1bb22, docs-only). Option B is the right structural fix and my earlier CHANGES_REQUESTED on vendor_wrapper.go is resolved by removal — every finding from that round is moot.
Validated by building aicr at head and generating a real --vendor-charts bundle for --service eks --accelerator h100 --os ubuntu --intent inference: 001-agentgateway-crds/ (wrapper + tarball, no templates/) + 002-agentgateway-crds-post/templates/*, and zero helm.sh/hook anywhere in the emitted bundle. go build ./... and go test ./pkg/bundler/deployer/localformat/... ./pkg/bundler/deployer/helmfile/... pass. Argo CD (waveForFolder, name-suffix keyed) and helmfile (CarriesPostManifests) both route the new folder correctly, and flux already had this shape.
CI is green and — unlike the previous round — the primary/-post split is genuinely exercised by unit tests. The one e2e assertion this PR adds is not; see the inline comment on chainsaw-test.yaml.
The blocker is the migration note in bundling.md, inline.
Non-blocking — four sites still document the removed "collapsed vendored folder" as current behavior. One root cause; the PR updated folder.go, doc.go, vendor_folder.go, vendor_wrapper.go, bundling.md and cli-reference.md but missed these. No changed-line anchor, so listing here:
docs/contributor/recipe.md#L104— published page: "the injected-postwrapper, or the collapsed vendored folder under--vendor-charts"pkg/bundler/deployer/localformat/writer.go#L101-L106—Options.VendorChartsgodoc, in a file this PR edits: "(for mixed components) post-install-hook templates. Mixed components no longer split into primary + -post."pkg/bundler/deployer/helmfile/releases.go#L261-L264pkg/recipe/components.go#L139-L141
Checked and deliberately not filed: CodeRabbit's "reject a post-phase Namespace matching Component.Namespace" — no shipped recipe puts a Namespace in manifestFiles; all five talos-namespace.yaml files attach via preManifestFiles in recipes/mixins/os-talos.yaml. The scenario is equally present on the non-vendored path, so it is pre-existing and unreachable, not something this PR introduces. Removing exported InjectPostInstallHooks is outside make api-diff scope (pkg/client/v1 closure) and has no remaining callers. The folderCount pre-pass and the emission conditions still agree for every vendored / kustomize / manifest-only shape.
Replace helm.sh/hook injection under --vendor-charts with the same <component>-post release the non-vendored path already uses. That closes upgrade drift, uninstall residue, and Argo CD PostSync silent-drop without the delete-then-recreate hazard of adding post-upgrade to before-hook-creation hooks (reviewers of #2061). Address review on #2061: safe Helm-adoption migration note (no CRD/Namespace delete), drop stale collapsed-folder docs, and assert -post in chainsaw. Fixes #1835 Signed-off-by: Rohit Rajani <[email protected]>
c412628 to
eb9d4fb
Compare
mchmarny
left a comment
There was a problem hiding this comment.
APPROVE — 0 blockers.
Re-reviewed at head eb9d4fb1 (previous round was c412628e). Both findings from that round are resolved:
- Blocker — the migration note prescribed a destructive
kubectl delete -f. Fixed.docs/user/bundling.mdnow states the redeploy fails with Helm ownership conflicts until each hook-era object is adopted or removed (hard precondition, not optional cleanup), leads with the non-destructivekubectl label/annotateadoption path, and carries an explicit do not delete for CRD/Namespace kinds namingagentgateway-crdsas the concrete risk. - Non-blocking — the chainsaw guard was vacuous for its fixture recipe. Fixed, and verified non-vacuous below.
- Non-blocking — four sites documented the removed "collapsed vendored folder". All four updated (
docs/contributor/recipe.md, theOptions.VendorChartsgodoc,helmfile/releases.go,pkg/recipe/components.go); a repo-wide grep finds no remaining reference.
Validated at this head by building aicr and generating a real --vendor-charts bundle for the test's own recipe (--service eks --accelerator h100 --os ubuntu --intent inference) against its fake helm:
- Emits
001-agentgateway-crds/+002-agentgateway-crds-post/and006-agentgateway/+007-agentgateway-post/. Primaries holdcharts/*.tgzand notemplates/; both-postfolders hold the recipe manifests;helm.sh/hookappears nowhere in the bundle; all four folders are covered bychecksums.txt. - Counterfactual on
main: the same recipe collapses to001-agentgateway-crds/templates/*and005-agentgateway/templates/*withhelm.sh/hook, and no-postfolder exists — so all three new chainsaw assertions fail onmain. The e2e guard now detects the regression it describes. go test -race ./pkg/bundler/... ./pkg/recipe/...andgolangci-lint run -c .golangci.yamlon the changed packages are clean.- Flux already emitted a separate
-postchart for mixed components regardless of vendoring (flux.goL511-537), so the two paths are now consistent rather than divergent, andInjectPostInstallHookshas no remaining callers anywhere in the tree.
CI is green at this exact SHA, including tests / CLI E2E (which runs the updated cli-bundle-vendor-charts) and the KWOK eks-inference Tier 1 lanes.
Branch is BEHIND main — mechanical only; update before merge.
| `templates/` if you still have that bundle): | ||
|
|
||
| ```bash | ||
| kubectl label <kind>/<name> app.kubernetes.io/managed-by=Helm --overwrite |
There was a problem hiding this comment.
Non-blocking — the adoption commands need -n <ns> for namespaced resources.
kubectl label <kind>/<name> … resolves against the operator's current context namespace, so for the namespaced half of the affected manifests it errors NotFound and the migration stalls partway through. Not hypothetical for the default inference bundle: 007-agentgateway-post/ ships a Gateway and an AgentgatewayParameters into agentgateway-system (its generated install.sh runs --namespace agentgateway-system --create-namespace). Across recipes/components/*/manifests/ roughly half the kinds are namespaced (ConfigMap, DaemonSet, Subscription, OperatorGroup, RoleBinding, PersistentVolumeClaim, LocalQueue, Gateway); the rest are cluster-scoped (CRD, ClusterQueue, ResourceFlavor, ClusterTrainingRuntime, NicClusterPolicy).
Minimum fix: add -n <ns> to both commands — the same <ns> already passed to meta.helm.sh/release-namespace — with a half-line noting it is omitted for cluster-scoped kinds.
There was a problem hiding this comment.
Follow-up: #2190 — adds -n <ns> to the adoption examples (same ns as meta.helm.sh/release-namespace) and notes to omit -n for cluster-scoped kinds.
Replace helm.sh/hook injection under --vendor-charts with the same <component>-post release the non-vendored path already uses. That closes upgrade drift, uninstall residue, and Argo CD PostSync silent-drop without the delete-then-recreate hazard of adding post-upgrade to before-hook-creation hooks (reviewers of #2061). Address review on #2061: safe Helm-adoption migration note (no CRD/Namespace delete), drop stale collapsed-folder docs, and assert -post in chainsaw. Fixes #1835 Signed-off-by: Rohit Rajani <[email protected]>
eb9d4fb to
7a8eeb4
Compare
Summary
Replace
--vendor-chartsHelm-hook injection for mixed-component recipe-side manifests with the same tracked<component>-postHelm release the non-vendored path already uses.This closes upgrade drift, uninstall residue, and Argo CD PostSync silent-drop without the delete-then-recreate hazard of adding
post-upgradetobefore-hook-creationhooks (blocking review on the earlier approach).Motivation / Context
Fixes: #1835
Related: review on #2061 (mchmarny, njhensley) — Option B / structural fix
Type of Change
Component(s) Affected
pkg/bundler,pkg/component/*)docs/,examples/)Implementation Notes
localformat.Writenow injects-postunderVendorCharts(same as upstream-Helm path).injectPostInstallHooks/writeMixedManifests; vendored primary wraps only the tarball.helm.sh/hookannotations on recipe manifests are stripped on the-postpath via existingstripHelmHooks— matching non-vendored. Ordering is preserved byNNN-folder sequencing.#kueueanchor removed.Testing
Coverage:
pkg/bundler/deployer/localformat75.7% → 75.4% (-0.3%)Risk Assessment
-postfolder); operators with old hook-based installs may need one-timekubectl deleteof orphaned hook resources (documented).Checklist
make testwith-race)make lint)git commit -S)