Skip to content

Commit 2077bdb

Browse files
authored
Reduce log verbosity (#2455)
Problem: NGF control plane logs are very verbose and give more information than is needed at the Info level. Solution: Reduce many logs to the debug level, including logs from the controller-runtime library. Tests will log at the debug level.
1 parent 6b146e6 commit 2077bdb

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

internal/framework/events/loop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ func (el *EventLoop) Start(ctx context.Context) error {
6969
el.currentBatchID++
7070
batchLogger := el.logger.WithName("eventHandler").WithValues("batchID", el.currentBatchID)
7171

72-
batchLogger.Info("Handling events from the batch", "total", len(batch))
72+
batchLogger.V(1).Info("Handling events from the batch", "total", len(batch))
7373

7474
el.handler.HandleEventBatch(ctx, batchLogger, batch)
7575

76-
batchLogger.Info("Finished handling the batch")
76+
batchLogger.V(1).Info("Finished handling the batch")
7777
handlingDone <- struct{}{}
7878
}(el.currentBatch)
7979
}
@@ -120,7 +120,7 @@ func (el *EventLoop) Start(ctx context.Context) error {
120120
// Add the event to the current batch.
121121
el.nextBatch = append(el.nextBatch, e)
122122

123-
el.logger.Info(
123+
el.logger.V(1).Info(
124124
"added an event to the next batch",
125125
"type", fmt.Sprintf("%T", e),
126126
"total", len(el.nextBatch),

internal/mode/static/manager.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ func StartManager(cfg config.Config) error {
282282
}
283283

284284
cfg.Logger.Info("Starting manager")
285+
go func() {
286+
<-ctx.Done()
287+
cfg.Logger.Info("Shutting down")
288+
}()
289+
285290
return mgr.Start(ctx)
286291
}
287292

@@ -306,7 +311,7 @@ func createPolicyManager(
306311
func createManager(cfg config.Config, nginxChecker *nginxConfiguredOnStartChecker) (manager.Manager, error) {
307312
options := manager.Options{
308313
Scheme: scheme,
309-
Logger: cfg.Logger,
314+
Logger: cfg.Logger.V(1),
310315
Metrics: getMetricsOptions(cfg.MetricsConfig),
311316
// Note: when the leadership is lost, the manager will return an error in the Start() method.
312317
// However, it will not wait for any Runnable it starts to finish, meaning any in-progress operations

internal/mode/static/nginx/file/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (m *ManagerImpl) ReplaceFiles(files []File) error {
103103
return fmt.Errorf("failed to delete file %q: %w", path, err)
104104
}
105105

106-
m.logger.Info("Deleted file", "path", path)
106+
m.logger.V(1).Info("Deleted file", "path", path)
107107
}
108108

109109
// In some cases, NGINX reads files in runtime, like a JWK. If you remove such file, NGINX will fail
@@ -118,7 +118,7 @@ func (m *ManagerImpl) ReplaceFiles(files []File) error {
118118
}
119119

120120
m.lastWrittenPaths = append(m.lastWrittenPaths, file.Path)
121-
m.logger.Info("Wrote file", "path", file.Path)
121+
m.logger.V(1).Info("Wrote file", "path", file.Path)
122122
}
123123

124124
return nil

tests/framework/ngf.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
6767
"--namespace", cfg.Namespace,
6868
"--wait",
6969
"--set", "nginxGateway.productTelemetry.enable=false",
70+
"--set", "nginxGateway.config.logging.level=debug",
7071
}
7172
if cfg.ChartVersion != "" {
7273
args = append(args, "--version", cfg.ChartVersion)
@@ -95,6 +96,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
9596
"--namespace", cfg.Namespace,
9697
"--wait",
9798
"--set", "nginxGateway.productTelemetry.enable=false",
99+
"--set", "nginxGateway.config.logging.level=debug",
98100
}
99101
if cfg.ChartVersion != "" {
100102
args = append(args, "--version", cfg.ChartVersion)

0 commit comments

Comments
 (0)