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:
parent
1c329ea65f
commit
47b1266503
3 changed files with 20 additions and 7 deletions
|
@ -2,7 +2,7 @@ package event
|
|||
|
||||
const eventWorkQueueName = "kyverno-events"
|
||||
|
||||
const workQueueRetryLimit = 10
|
||||
const workQueueRetryLimit = 3
|
||||
|
||||
// Info defines the event details
|
||||
type Info struct {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue