From f23b9a500272c4c6ffaf2a577762f9e2e4370494 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 31 Mar 2022 01:50:24 -0400 Subject: [PATCH] Avoid log spam in servers without auditing enabled --- staging/src/k8s.io/apiserver/pkg/audit/context.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/audit/context.go b/staging/src/k8s.io/apiserver/pkg/audit/context.go index 122666546fc..df429af37d5 100644 --- a/staging/src/k8s.io/apiserver/pkg/audit/context.go +++ b/staging/src/k8s.io/apiserver/pkg/audit/context.go @@ -18,7 +18,6 @@ package audit import ( "context" - "fmt" "sync" auditinternal "k8s.io/apiserver/pkg/apis/audit" @@ -73,7 +72,7 @@ func WithAuditAnnotations(parent context.Context) context.Context { func AddAuditAnnotation(ctx context.Context, key, value string) { mutex, ok := auditAnnotationsMutex(ctx) if !ok { - klog.ErrorS(nil, "Attempted to add audit annotations from unsupported request chain", "annotation", fmt.Sprintf("%s=%s", key, value)) + // auditing is not enabled return } @@ -95,7 +94,7 @@ func AddAuditAnnotation(ctx context.Context, key, value string) { func AddAuditAnnotations(ctx context.Context, keysAndValues ...string) { mutex, ok := auditAnnotationsMutex(ctx) if !ok { - klog.ErrorS(nil, "Attempted to add audit annotations from unsupported request chain", "annotations", keysAndValues) + // auditing is not enabled return } @@ -121,7 +120,7 @@ func AddAuditAnnotations(ctx context.Context, keysAndValues ...string) { func AddAuditAnnotationsMap(ctx context.Context, annotations map[string]string) { mutex, ok := auditAnnotationsMutex(ctx) if !ok { - klog.ErrorS(nil, "Attempted to add audit annotations from unsupported request chain", "annotations", annotations) + // auditing is not enabled return } @@ -154,7 +153,7 @@ func addAuditAnnotationLocked(ae *auditinternal.Event, annotations *[]annotation func addAuditAnnotationsFrom(ctx context.Context, ev *auditinternal.Event) { mutex, ok := auditAnnotationsMutex(ctx) if !ok { - klog.Errorf("Attempted to copy audit annotations from unsupported request chain") + // auditing is not enabled return }