Skip to content

fix(templating): hooks conflicting with templates in post-renderers#32049

Merged
banjoh merged 2 commits into
helm:mainfrom
fluxcd:fix-flux2-5791
Apr 21, 2026
Merged

fix(templating): hooks conflicting with templates in post-renderers#32049
banjoh merged 2 commits into
helm:mainfrom
fluxcd:fix-flux2-5791

Conversation

@matheuscscp

@matheuscscp matheuscscp commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores Helm 3–style behavior for post-renderers by preventing hook resources from being merged into the same YAML stream as regular templates before post-rendering, avoiding duplicate-resource failures (e.g., with Kustomize) when hooks and templates overlap.

Changes:

  • Split hook manifests and non-hook manifests into separate streams before running the post-renderer, then recombine the results.
  • Add a regression test covering a duplicate resource declared both as a hook and as a normal template.
  • Update an existing post-renderer merge-error test assertion to match the new error surfaced from manifest sorting/parsing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/action/action.go Post-render hooks and templates separately and merge outputs back into the file map before final sorting.
pkg/action/action_test.go Add regression coverage for hook/template duplicate resources; adjust expected error substring for merge/parse failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/action/action.go Outdated
@promptless-for-oss

Copy link
Copy Markdown

Promptless prepared a documentation update related to this change.

Triggered by PR #32049

Documents that in Helm 4, chart hooks are processed by post-renderers as separate streams from templates, allowing the same resource (like a ServiceAccount) to appear in both without conflict.

Review: Document post-render hooks behavior

Copilot AI review requested due to automatic review settings April 16, 2026 18:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/action/install.go Outdated
Comment thread pkg/action/upgrade.go Outdated
Copilot AI review requested due to automatic review settings April 16, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/action/install.go
Comment thread pkg/action/upgrade.go
Comment thread pkg/action/action.go
Comment thread pkg/action/action.go Outdated
Copilot AI review requested due to automatic review settings April 16, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/action/action.go
Comment thread pkg/action/action.go Outdated

@banjoh banjoh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review of code looks good. I'll need to run some manual tests to validate the functionality won't cause regressions

@matheuscscp

Copy link
Copy Markdown
Contributor Author

When enabling separated in helm-controller here we got hit by this:

https://github.com/fluxcd/helm-controller/actions/runs/24562698653/job/71815023770?pr=1460

This test shows an obvious flaw in streaming hooks and templates separately to a Kustomize post-renderer: patches targeting templates will error out in the hooks stream.

Conclusion: We need to ship nohooks (as per @gjenkins8 comment here). Flux will default to nohooks in 2.8 and add support for combined and separate in 2.9.

Copilot AI review requested due to automatic review settings April 17, 2026 13:27
@pull-request-size pull-request-size Bot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 17, 2026
@pull-request-size pull-request-size Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/action/install.go
Comment thread pkg/action/action.go

@TerryHowe TerryHowe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@banjoh banjoh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@banjoh banjoh merged commit 8f56f24 into helm:main Apr 21, 2026
8 of 9 checks passed
@promptless-for-oss

Copy link
Copy Markdown

Promptless prepared a documentation update related to this change.

Triggered by PR #32049

Updated documentation to clarify all three PostRenderStrategy options (combined, separate, nohooks) and added guidance that nohooks is recommended for Kustomize/Flux users with patches targeting template-only resources.

Review: Document post-renderer hooks behavior in Helm 4

@matheuscscp matheuscscp deleted the fix-flux2-5791 branch April 24, 2026 17:15
caretak3r added a commit to caretak3r/helm that referenced this pull request Apr 27, 2026
Resolves conflicts introduced by upstream's PostRenderStrategy work
(helm#32049) and Go 1.26 / Kubernetes 1.36 / kstatus 1.1 bump (helm#32078)
against the HIP-0025 sequencing changes.

Conflict resolution:
- pkg/action/action.go: combined upstream's three-way post-render
  strategy switch with the renderResources/renderResourcesWithFiles
  split from this branch; all error returns from
  renderResourcesWithFiles updated to the 5-tuple shape.
- pkg/action/install.go: thread PostRenderStrategy through both the
  ordered-wait (renderResourcesWithFiles) and standard
  (renderResources) render paths.
- pkg/action/upgrade.go: same thread-through, plus restore the
  5-tuple cerr return.
- pkg/action/uninstall.go: pass PostRenderStrategyCombined to the
  recovery path that re-renders manifests for sequenced uninstall.

Also:
- gofmt fixes for pkg/kube/readiness.go (strconv import indent;
  flagged by Copilot review) and pkg/action/rollback.go (struct
  field alignment).
- Add post-rewrite contract tests for BuildSubchartDAG covering
  metadata-only-with-no-loaded-deps and annotation-references-
  unloaded-dep cases (locks in joejulian's review feedback).
- .gitignore: ignore .mission/ tooling directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

5 participants