1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

- Disable events generation on DELETE; - Reduce event generation retry from 10 to 3 (#4159)

Signed-off-by: ShutingZhao <shuting@nirmata.com>
This commit is contained in:
shuting 2022-06-28 11:58:23 +08:00 committed by GitHub
parent 1c329ea65f
commit 47b1266503
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 7 deletions

View file

@ -2,7 +2,7 @@ package event
const eventWorkQueueName = "kyverno-events"
const workQueueRetryLimit = 10
const workQueueRetryLimit = 3
// Info defines the event details
type Info struct {

View file

@ -359,8 +359,10 @@ func (h *handlers) handleMutation(logger logr.Logger, request *admissionv1.Admis
// all policies were applied successfully.
// create an event on the resource
// ADD EVENTS
events := generateEvents(engineResponses, false, logger)
h.eventGen.Add(events...)
if deletionTimeStamp == nil {
events := generateEvents(engineResponses, false, logger)
h.eventGen.Add(events...)
}
// debug info
func() {
@ -430,9 +432,18 @@ func (h *handlers) handleVerifyImages(logger logr.Logger, request *admissionv1.A
prInfos := policyreport.GeneratePRsFromEngineResponse(engineResponses, logger)
h.prGenerator.Add(prInfos...)
var deletionTimeStamp *metav1.Time
if reflect.DeepEqual(policyContext.NewResource, unstructured.Unstructured{}) {
deletionTimeStamp = policyContext.NewResource.GetDeletionTimestamp()
} else {
deletionTimeStamp = policyContext.OldResource.GetDeletionTimestamp()
}
blocked := toBlockResource(engineResponses, logger)
events := generateEvents(engineResponses, blocked, logger)
h.eventGen.Add(events...)
if deletionTimeStamp == nil {
events := generateEvents(engineResponses, blocked, logger)
h.eventGen.Add(events...)
}
if blocked {
logger.V(4).Info("resource blocked")

View file

@ -94,8 +94,10 @@ func (v *validationHandler) handleValidation(
// Scenario 3:
// all policies were applied successfully.
// create an event on the resource
events := generateEvents(engineResponses, blocked, logger)
v.eventGen.Add(events...)
if deletionTimeStamp == nil {
events := generateEvents(engineResponses, blocked, logger)
v.eventGen.Add(events...)
}
if blocked {
logger.V(4).Info("resource blocked")