From 548ba5228bf2ac96c47888fd33131912ca7e877d Mon Sep 17 00:00:00 2001 From: rosstimothy <39066650+rosstimothy@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:05:43 -0500 Subject: [PATCH] Reduce log spam generated by conflicting session_id and event_index (#48548) Alters the log messages from https://github.com/gravitational/teleport/pull/40854 such that they only occur if the fallback mechanism fails. Updates https://github.com/gravitational/teleport/issues/46801 --- lib/events/dynamoevents/dynamoevents.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/events/dynamoevents/dynamoevents.go b/lib/events/dynamoevents/dynamoevents.go index d5ec6c821a490..c5a871a231bbb 100644 --- a/lib/events/dynamoevents/dynamoevents.go +++ b/lib/events/dynamoevents/dynamoevents.go @@ -466,11 +466,17 @@ func (l *Log) putAuditEvent(ctx context.Context, sessionID string, in apievents. // item event index/session id. Since we can't change the session // id, update the event index with a new value and retry the put // item. - l. - WithError(err). - WithFields(log.Fields{"event_type": in.GetType(), "session_id": sessionID, "event_index": in.GetIndex()}). - Error("Conflict on event session_id and event_index") - return trace.Wrap(l.handleConditionError(ctx, err, sessionID, in)) + if err2 := l.handleConditionError(ctx, err, sessionID, in); err2 != nil { + // Only log about the original conflict if updating + // the session information fails. + l. + WithError(err). + WithFields(log.Fields{"event_type": in.GetType(), "session_id": sessionID, "event_index": in.GetIndex()}). + Error("Conflict on event session_id and event_index") + return trace.Wrap(err2) + } + + return nil } return err