Skip to content

Fix nil hook output callback panic - #1604

Merged
matheuscscp merged 1 commit into
fluxcd:mainfrom
lubronzhan:hook-output-logs
Oct 16, 2026
Merged

matheuscscp merged 1 commit into
fluxcd:mainfrom
lubronzhan:hook-output-logs

Conversation

@lubronzhan

@lubronzhan lubronzhan commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1562.

Initialize HookOutputFunc to return io.Discard, matching Helm's default and preventing a nil callback panic when hooks use helm.sh/hook-output-log-policy. Hook logs are not forwarded to controller logs or events.

Credit to @pujitha24 for the original fix in #1563. This PR adopts that approach following maintainer feedback, with regression coverage for successful and interrupted log streams and configuration without a logger.

Validation: make tidy fmt vet && make test.

This PR was written in part with the assistance of generative AI.

Comment thread internal/action/log.go Outdated
@matheuscscp

matheuscscp commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

@lubronzhan After #1562 (comment) I think I prefer to just fix the panic for now. Let's not wire these logs yet. Sorry for all the churn!

@lubronzhan lubronzhan changed the title Forward Hook output logs to helm controller Fix nil hook output callback panic Oct 16, 2026
@lubronzhan

lubronzhan commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

@lubronzhan After #1562 (comment) I think I prefer to just fix the panic for now. Let's not wire these logs yet. Sorry for all the churn!

Hi @matheuscscp no worries it totally make sense. I updated it

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Thanks @lubronzhan

@matheuscscp

Copy link
Copy Markdown
Member

Please rebase (no merge commits pls), squash all commits into one, and force-push 🙏

Default the hook output callback to io.Discard so annotated hooks
can collect container logs without a nil callback panic. Add coverage
for successful and interrupted streams and builds without a logger.

Signed-off-by: lubronzhan <lubronzhan@gmail.com>
Assisted-by: Codex/gpt-6
@lubronzhan

Copy link
Copy Markdown
Contributor Author

Got it. Done

@matheuscscp
matheuscscp merged commit 49e2112 into fluxcd:main Oct 16, 2026
6 checks passed
@lubronzhan
lubronzhan deleted the hook-output-logs branch October 17, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

helm-controller panics on hooks with helm.sh/hook-output-log-policy (nil HookOutputFunc)

2 participants