Skip to content

Commit

Permalink
Reduce log verbosity (#2455)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjberman authored Aug 22, 2024
1 parent 6b146e6 commit 2077bdb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions internal/framework/events/loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (el *EventLoop) Start(ctx context.Context) error {
el.currentBatchID++
batchLogger := el.logger.WithName("eventHandler").WithValues("batchID", el.currentBatchID)

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

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

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

el.logger.Info(
el.logger.V(1).Info(
"added an event to the next batch",
"type", fmt.Sprintf("%T", e),
"total", len(el.nextBatch),
Expand Down
7 changes: 6 additions & 1 deletion internal/mode/static/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ func StartManager(cfg config.Config) error {
}

cfg.Logger.Info("Starting manager")
go func() {
<-ctx.Done()
cfg.Logger.Info("Shutting down")
}()

return mgr.Start(ctx)
}

Expand All @@ -306,7 +311,7 @@ func createPolicyManager(
func createManager(cfg config.Config, nginxChecker *nginxConfiguredOnStartChecker) (manager.Manager, error) {
options := manager.Options{
Scheme: scheme,
Logger: cfg.Logger,
Logger: cfg.Logger.V(1),
Metrics: getMetricsOptions(cfg.MetricsConfig),
// Note: when the leadership is lost, the manager will return an error in the Start() method.
// However, it will not wait for any Runnable it starts to finish, meaning any in-progress operations
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/nginx/file/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (m *ManagerImpl) ReplaceFiles(files []File) error {
return fmt.Errorf("failed to delete file %q: %w", path, err)
}

m.logger.Info("Deleted file", "path", path)
m.logger.V(1).Info("Deleted file", "path", path)
}

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

m.lastWrittenPaths = append(m.lastWrittenPaths, file.Path)
m.logger.Info("Wrote file", "path", file.Path)
m.logger.V(1).Info("Wrote file", "path", file.Path)
}

return nil
Expand Down
2 changes: 2 additions & 0 deletions tests/framework/ngf.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func InstallNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
"--namespace", cfg.Namespace,
"--wait",
"--set", "nginxGateway.productTelemetry.enable=false",
"--set", "nginxGateway.config.logging.level=debug",
}
if cfg.ChartVersion != "" {
args = append(args, "--version", cfg.ChartVersion)
Expand Down Expand Up @@ -95,6 +96,7 @@ func UpgradeNGF(cfg InstallationConfig, extraArgs ...string) ([]byte, error) {
"--namespace", cfg.Namespace,
"--wait",
"--set", "nginxGateway.productTelemetry.enable=false",
"--set", "nginxGateway.config.logging.level=debug",
}
if cfg.ChartVersion != "" {
args = append(args, "--version", cfg.ChartVersion)
Expand Down

0 comments on commit 2077bdb

Please sign in to comment.