From 2ce205b9e95b369a5a13f8ee8d0d0c84201459b6 Mon Sep 17 00:00:00 2001 From: Prateek Pandey Date: Mon, 28 Mar 2022 11:31:33 +0530 Subject: [PATCH] use mutex as field instead of embedded (#3480) --- pkg/webhooks/generation.go | 4 ++-- pkg/webhooks/server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/webhooks/generation.go b/pkg/webhooks/generation.go index 0e50c59e7e..a4ad2dd5cf 100644 --- a/pkg/webhooks/generation.go +++ b/pkg/webhooks/generation.go @@ -207,10 +207,10 @@ func (ws *WebhookServer) updateAnnotationInGR(gr *kyverno.GenerateRequest, logge if len(grAnnotations) == 0 { grAnnotations = make(map[string]string) } - ws.Lock() + ws.mu.Lock() grAnnotations["generate.kyverno.io/updation-time"] = time.Now().String() gr.SetAnnotations(grAnnotations) - ws.Unlock() + ws.mu.Unlock() _, err := ws.kyvernoClient.KyvernoV1().GenerateRequests(config.KyvernoNamespace).Update(contextdefault.TODO(), gr, metav1.UpdateOptions{}) if err != nil { logger.Error(err, "failed to update generate request for the resource", "generate request", gr.Name) diff --git a/pkg/webhooks/server.go b/pkg/webhooks/server.go index 7adb932aa7..bcfe4b860e 100644 --- a/pkg/webhooks/server.go +++ b/pkg/webhooks/server.go @@ -126,7 +126,7 @@ type WebhookServer struct { promConfig *metrics.PromConfig - sync.RWMutex + mu sync.RWMutex } // NewWebhookServer creates new instance of WebhookServer accordingly to given configuration