Default HookOutputFunc to io.Discard to fix panic on hook-output-log-policy - #1563
Open
pujitha24 wants to merge 1 commit into
Open
Default HookOutputFunc to io.Discard to fix panic on hook-output-log-policy#1563pujitha24 wants to merge 1 commit into
pujitha24 wants to merge 1 commit into
Conversation
…policy Motivation: helm-controller crashes with a nil pointer dereference whenever a chart hook Pod/Job carries the `helm.sh/hook-output-log-policy` annotation, because Helm dereferences `cfg.HookOutputFunc` without a nil check, and `ConfigFactory.Build()` never set that field. Approach: Set `HookOutputFunc` on the configuration returned by `ConfigFactory.Build()` in internal/action/config.go to a function returning `io.Discard`, matching the default Helm's own CLI initialization uses, so hook container logs are discarded instead of causing a nil dereference. Validation: Added a unit test in internal/action/config_test.go asserting `ConfigFactory.Build().HookOutputFunc` is non-nil and returns `io.Discard`. Report: fluxcd#1562 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
helm-controller crashes with a nil pointer dereference whenever a chart hook Pod/Job carries the
helm.sh/hook-output-log-policyannotation, because Helm dereferencescfg.HookOutputFuncwithout a nil check, andConfigFactory.Build()never set that field.Approach:
Set
HookOutputFuncon the configuration returned byConfigFactory.Build()in internal/action/config.go to a function returningio.Discard, matching the default Helm's own CLI initialization uses, so hook container logs are discarded instead of causing a nil dereference.Validation:
Added a unit test in internal/action/config_test.go asserting
ConfigFactory.Build().HookOutputFuncis non-nil and returnsio.Discard.Report: #1562
Signed-off-by: Pujitha Paladugu 10557236+pujitha24@users.noreply.github.com
Assisted-by: claude-sonnet-5 (via Claude Code)