diff --git a/internal/controller/helmrelease_controller.go b/internal/controller/helmrelease_controller.go index afd58a6a2..fa96e5cac 100644 --- a/internal/controller/helmrelease_controller.go +++ b/internal/controller/helmrelease_controller.go @@ -715,7 +715,7 @@ func (r *HelmReleaseReconciler) handleHelmActionResult(ctx context.Context, err = fmt.Errorf("Helm %s failed: %w", action, err) msg := err.Error() if actionErr := (*runner.ActionError)(nil); errors.As(err, &actionErr) { - msg = msg + "\n\nLast Helm logs:\n\n" + actionErr.CapturedLogs + msg = strings.TrimSpace(msg) + "\n\nLast Helm logs:\n\n" + actionErr.CapturedLogs } newCondition := metav1.Condition{ Type: condition, diff --git a/internal/runner/runner.go b/internal/runner/runner.go index be0bd355a..0488054f1 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -78,13 +78,22 @@ func NewRunner(getter genericclioptions.RESTClientGetter, storageNamespace strin runner := &Runner{ logBuffer: NewLogBuffer(NewDebugLog(logger.V(runtimelogger.DebugLevel)), defaultBufferSize), } + + // Default to the trace level logger for the Helm action configuration, + // to ensure storage logs are captured. cfg := new(action.Configuration) if err := cfg.Init(getter, storageNamespace, "secret", NewDebugLog(logger.V(runtimelogger.TraceLevel))); err != nil { return nil, err } - // Override the logger used by the Helm actions with the log buffer. + + // Override the logger used by the Helm actions and Kube client with the log buffer, + // which provides useful information in the event of an error. cfg.Log = runner.logBuffer.Log + if kc, ok := cfg.KubeClient.(*kube.Client); ok { + kc.Log = runner.logBuffer.Log + } runner.config = cfg + return runner, nil }