From e9e16ba856d66618f0a8ab20ff220f2f925fa9c9 Mon Sep 17 00:00:00 2001 From: Russell Jones Date: Sat, 16 Mar 2024 17:17:38 -0700 Subject: [PATCH] Don't emit logs on Cloud. (#39462) Updated `events.LoggingEmitter` to detect if running on Cloud both cluster features and modules. --- lib/events/emitter.go | 4 ++-- lib/service/service.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/events/emitter.go b/lib/events/emitter.go index 34858f937e28b..9a2c5e6c599d2 100644 --- a/lib/events/emitter.go +++ b/lib/events/emitter.go @@ -250,9 +250,9 @@ func (w *WriterEmitter) EmitAuditEvent(ctx context.Context, event apievents.Audi // NewLoggingEmitter returns an emitter that logs all events to the console // with the info level. Events are only logged for self-hosted installations, // Teleport Cloud treats this as a no-op. -func NewLoggingEmitter() *LoggingEmitter { +func NewLoggingEmitter(cloud bool) *LoggingEmitter { return &LoggingEmitter{ - emit: !modules.GetModules().Features().Cloud, + emit: !(modules.GetModules().Features().Cloud || cloud), } } diff --git a/lib/service/service.go b/lib/service/service.go index 9c0306c4e10c6..be5803c4b9466 100644 --- a/lib/service/service.go +++ b/lib/service/service.go @@ -1785,7 +1785,7 @@ func (process *TeleportProcess) initAuthService() error { } checkingEmitter, err := events.NewCheckingEmitter(events.CheckingEmitterConfig{ - Inner: events.NewMultiEmitter(events.NewLoggingEmitter(), emitter), + Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.getClusterFeatures().Cloud), emitter), Clock: process.Clock, ClusterName: clusterName, }) @@ -2459,7 +2459,7 @@ func (process *TeleportProcess) proxyPublicAddr() utils.NetAddr { // It is caller's responsibility to call Close on the emitter once done. func (process *TeleportProcess) NewAsyncEmitter(clt apievents.Emitter) (*events.AsyncEmitter, error) { emitter, err := events.NewCheckingEmitter(events.CheckingEmitterConfig{ - Inner: events.NewMultiEmitter(events.NewLoggingEmitter(), clt), + Inner: events.NewMultiEmitter(events.NewLoggingEmitter(process.getClusterFeatures().Cloud), clt), Clock: process.Clock, }) if err != nil {