Skip to content

Commit c9da495

Browse files
committed
runner: configure Helm action cfg log levels
This reduces the amount of log lines pushed to `debug` by configuring the kube client and storage loggers to only log to `trace`. In addition, the log buffer used in events will now just contain the most relevant information about a failure as reported by the Helm action itself, and not the in-depth information from the underyling client and/or storage. Signed-off-by: Hidde Beydals <hidde@hhh.computer>
1 parent f1a270a commit c9da495

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

internal/runner/log_buffer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func NewDebugLog(log logr.Logger) *DebugLog {
3737
}
3838

3939
func (l *DebugLog) Log(format string, v ...interface{}) {
40-
l.log.V(1).Info(fmt.Sprintf(format, v...))
40+
l.log.Info(fmt.Sprintf(format, v...))
4141
}
4242

4343
type LogBuffer struct {

internal/runner/runner.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import (
4242
"k8s.io/apimachinery/pkg/runtime"
4343
"k8s.io/apimachinery/pkg/runtime/schema"
4444

45+
runtimelogger "github.com/fluxcd/pkg/runtime/logger"
46+
4547
v2 "github.com/fluxcd/helm-controller/api/v2beta1"
4648
"github.com/fluxcd/helm-controller/internal/features"
4749
)
@@ -74,12 +76,15 @@ type Runner struct {
7476
// namespace configured to the provided values.
7577
func NewRunner(getter genericclioptions.RESTClientGetter, storageNamespace string, logger logr.Logger) (*Runner, error) {
7678
runner := &Runner{
77-
logBuffer: NewLogBuffer(NewDebugLog(logger).Log, defaultBufferSize),
79+
logBuffer: NewLogBuffer(NewDebugLog(logger.V(runtimelogger.DebugLevel)).Log, defaultBufferSize),
7880
}
79-
runner.config = new(action.Configuration)
80-
if err := runner.config.Init(getter, storageNamespace, "secret", runner.logBuffer.Log); err != nil {
81+
cfg := new(action.Configuration)
82+
if err := cfg.Init(getter, storageNamespace, "secret", NewDebugLog(logger.V(runtimelogger.TraceLevel)).Log); err != nil {
8183
return nil, err
8284
}
85+
// Override the logger used by the Helm actions with the log buffer.
86+
cfg.Log = runner.logBuffer.Log
87+
runner.config = cfg
8388
return runner, nil
8489
}
8590

0 commit comments

Comments
 (0)