From d07058e90f7a57261d177e4ad3f91004099a0035 Mon Sep 17 00:00:00 2001 From: Pooja Singh <36136335+NoSkillGirl@users.noreply.github.com> Date: Tue, 8 Dec 2020 01:34:46 +0530 Subject: [PATCH] skipping gr status update (#1364) --- pkg/generate/generate.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/generate/generate.go b/pkg/generate/generate.go index f8bef8842c..62d01a33d1 100644 --- a/pkg/generate/generate.go +++ b/pkg/generate/generate.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "reflect" + "strings" "time" "github.com/go-logr/logr" @@ -47,6 +48,12 @@ func (c *Controller) processGR(gr *kyverno.GenerateRequest) error { events := failedEvents(err, *gr, *resource) c.eventGen.Add(events...) + // Need not update the stauts when policy doesn't apply on resource, because all the generate requests are removed by the cleanup controller + if err != nil && strings.Contains(err.Error(), "does not apply to resource") { + logger.V(4).Info("skipping updating status of generate request") + return nil + } + // 4 - Update Status return updateStatus(c.statusControl, *gr, err, genResources) }