1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

[Feat] TTL controller log improvements (#8112)

* upgraded verbose and enhanced label

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

* enhancements

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

* fix

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

* fix

Signed-off-by: Ved Ratan <vedratan8@gmail.com>

---------

Signed-off-by: Ved Ratan <vedratan8@gmail.com>
This commit is contained in:
Ved Ratan 2023-08-26 02:02:56 +05:30 committed by GitHub
parent c751f1de58
commit ebd9506f87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View file

@ -2,6 +2,7 @@ package resource
import (
"context"
"fmt"
"time"
"github.com/go-logr/logr"
@ -18,7 +19,7 @@ func Validate(ctx context.Context, logger logr.Logger, request handlers.Admissio
}
if err := validation.ValidateTtlLabel(ctx, metadata); err != nil {
logger.Error(err, "metadatas validation errors")
return admissionutils.ResponseSuccess(request.UID, err.Error())
return admissionutils.ResponseSuccess(request.UID, fmt.Sprintf("cleanup.kyverno.io/ttl label value cannot be parsed as any recognizable format (%s)", err.Error()))
}
return admissionutils.ResponseSuccess(request.UID)
}

View file

@ -97,19 +97,19 @@ func (c *controller) handleUpdate(oldObj, newObj interface{}) {
func (c *controller) Start(ctx context.Context, workers int) {
for i := 0; i < workers; i++ {
c.wg.StartWithContext(ctx, func(ctx context.Context) {
defer c.logger.Info("worker stopped")
c.logger.Info("worker starting ....")
defer c.logger.V(3).Info("worker stopped")
c.logger.V(3).Info("worker starting ....")
wait.UntilWithContext(ctx, c.worker, 1*time.Second)
})
}
}
func (c *controller) Stop() {
defer c.logger.Info("queue stopped")
defer c.logger.V(3).Info("queue stopped")
defer c.wg.Wait()
// Unregister the event handlers
c.deregisterEventHandlers()
c.logger.Info("queue stopping ....")
c.logger.V(3).Info("queue stopping ....")
c.queue.ShutDown()
}
@ -129,7 +129,7 @@ func (c *controller) deregisterEventHandlers() {
c.logger.Error(err, "failed to deregister event handlers")
return
}
c.logger.Info("deregistered event handlers")
c.logger.V(3).Info("deregistered event handlers")
}
func (c *controller) worker(ctx context.Context) {

View file

@ -130,7 +130,7 @@ func (m *manager) start(ctx context.Context, gvr schema.GroupVersionResource, wo
cont, cancel := context.WithCancel(ctx)
var wg wait.Group
wg.StartWithContext(cont, func(ctx context.Context) {
logger.Info("informer starting...")
logger.V(3).Info("informer starting...")
informer.Informer().Run(cont.Done())
})
stopInformer := func() {
@ -148,7 +148,7 @@ func (m *manager) start(ctx context.Context, gvr schema.GroupVersionResource, wo
stopInformer()
return err
}
logger.Info("controller starting...")
logger.V(3).Info("controller starting...")
controller.Start(cont, workers)
m.resController[gvr] = func() {
stopInformer()
@ -169,8 +169,8 @@ func (m *manager) filterPermissionsResource(resources []schema.GroupVersionResou
}
func (m *manager) reconcile(ctx context.Context, workers int) error {
defer m.logger.Info("manager reconciliation done")
m.logger.Info("start manager reconciliation")
defer m.logger.V(3).Info("manager reconciliation done")
m.logger.V(3).Info("beginning reconciliation", "interval", m.interval)
desiredState, err := m.getDesiredState()
if err != nil {
return err