1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-15 17:51:20 +00:00

fix: record configmap resource version to not reload when version didn't change (#7007)

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
Charles-Edouard Brétéché 2023-04-25 18:17:25 +02:00 committed by GitHub
parent 8d52c1366b
commit cc66f2e402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,10 +40,11 @@ type controller struct {
queue workqueue.RateLimitingInterface
// config
controllerName string
logger logr.Logger
name string
callback callback
controllerName string
logger logr.Logger
name string
callback callback
resourceVersion string
}
type callback func(context.Context, *corev1.ConfigMap) error
@ -104,5 +105,13 @@ func (c *controller) doReconcile(ctx context.Context, logger logr.Logger) error
}
return c.callback(ctx, nil)
}
return c.callback(ctx, observed)
if c.resourceVersion == observed.ResourceVersion {
return nil
}
if err := c.callback(ctx, observed); err != nil {
return err
}
// record resource version
c.resourceVersion = observed.ResourceVersion
return nil
}