Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 reduce log verbosity for queueing operations #3073

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/crds/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func CRD(fs embed.FS, gr metav1.GroupResource) (*apiextensionsv1.CustomResourceD
func CreateSingle(ctx context.Context, client apiextensionsv1client.CustomResourceDefinitionInterface, rawCRD *apiextensionsv1.CustomResourceDefinition) error {
logger := klog.FromContext(ctx).WithValues("crd", rawCRD.Name)
start := time.Now()
logger.V(4).Info("bootstrapping CRD")
logger.V(2).Info("bootstrapping CRD")

updateNeeded := false
crd, err := client.Get(ctx, rawCRD.Name, metav1.GetOptions{})
Expand Down
4 changes: 2 additions & 2 deletions pkg/proxy/index/index_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down Expand Up @@ -213,7 +213,7 @@ func (c *Controller) process(ctx context.Context, key string) error {
defer c.lock.Unlock()

if _, found := c.shardWorkspaceInformers[shard.Name]; !found {
logger.V(1).Info("Starting informers for Shard")
logger.V(2).Info("Starting informers for Shard")

client, err := c.clientGetter(shard)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/apis/apibinding/apibinding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (c *controller) enqueueAPIBinding(apiBinding *apisv1alpha1.APIBinding, logg
return
}

logging.WithQueueKey(logger, key).V(2).Info(fmt.Sprintf("queueing APIBinding%s", logSuffix))
logging.WithQueueKey(logger, key).V(4).Info(fmt.Sprintf("queueing APIBinding%s", logSuffix))
c.queue.Add(key)
}

Expand Down Expand Up @@ -427,7 +427,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (c *Controller) enqueue(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing APIBinding")
logger.V(4).Info("queueing APIBinding")
c.queue.Add(key)
}

Expand Down Expand Up @@ -168,7 +168,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand All @@ -186,7 +186,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {
if errors.As(err, &estimate) {
t := estimate.Estimate/2 + 1
duration := time.Duration(t) * time.Second
logger.V(2).Info("custom resources remaining for APIBinding, waiting", "duration", duration)
logger.V(3).Info("custom resources remaining for APIBinding, waiting", "duration", duration)
c.queue.AddAfter(key, duration)
} else {
// rather than wait for a full resync, re-add the workspace to the queue to be processed
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/apis/apiexport/apiexport_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (c *controller) enqueueAllAPIExports(shard *corev1alpha1.Shard) {
continue
}

logging.WithQueueKey(logger, key).V(2).Info("queuing APIExport because Shard changed")
logging.WithQueueKey(logger, key).V(3).Info("queuing APIExport because Shard changed")
c.queue.Add(key)
}
}
Expand All @@ -248,7 +248,7 @@ func (c *controller) enqueueSecret(secret *corev1.Secret) {
runtime.HandleError(err)
return
}
logging.WithQueueKey(logger, key).V(2).Info("queueing APIExport via identity Secret")
logging.WithQueueKey(logger, key).V(3).Info("queueing APIExport via identity Secret")
c.queue.Add(key)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/apis/crdcleanup/crdcleanup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (c *controller) enqueueFromAPIBinding(oldBinding, newBinding *apisv1alpha1.

for uid := range uidSet {
key := kcpcache.ToClusterAwareKey(apibinding.SystemBoundCRDsClusterName.String(), "", uid)
logging.WithQueueKey(logger, key).V(2).Info("queueing CRD via APIBinding")
logging.WithQueueKey(logger, key).V(3).Info("queueing CRD via APIBinding")
c.queue.Add(key)
}
}
Expand Down Expand Up @@ -242,7 +242,7 @@ func (c *controller) process(ctx context.Context, key string) error {
return nil
}

logger.V(1).Info("Deleting CRD")
logger.V(2).Info("Deleting CRD")
if err := c.deleteCRD(ctx, obj.Name); err != nil {
if errors.IsNotFound(err) {
return nil // object deleted before we handled it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (c *controller) enqueueAPIBinding(obj interface{}, logger logr.Logger, logS
return
}

logging.WithQueueKey(logger, key).V(2).Info(fmt.Sprintf("queueing APIBinding%s", logSuffix))
logging.WithQueueKey(logger, key).V(4).Info(fmt.Sprintf("queueing APIBinding%s", logSuffix))
c.queue.Add(key)
}

Expand Down Expand Up @@ -209,7 +209,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down Expand Up @@ -265,7 +265,7 @@ func (c *controller) process(ctx context.Context, key string) error {
return nil
}

logger.V(1).Info("patching APIBinding extra annotations", "patch", string(patchBytes))
logger.V(2).Info("patching APIBinding extra annotations", "patch", string(patchBytes))
_, err = c.kcpClusterClient.Cluster(clusterName.Path()).ApisV1alpha1().APIBindings().Patch(ctx, name, types.MergePatchType, patchBytes, metav1.PatchOptions{})
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (c *controller) enqueueAPIBinding(obj interface{}, logger logr.Logger) {
return
}

logging.WithQueueKey(logger, key).V(2).Info("queueing APIBinding")
logging.WithQueueKey(logger, key).V(4).Info("queueing APIBinding")
c.queue.Add(key)
}

Expand Down Expand Up @@ -161,7 +161,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (c *resourceController) enqueueForResource(logger logr.Logger, gvr schema.G
}

queueKey += "::" + key
logging.WithQueueKey(logger, queueKey).V(2).Info("queuing resource")
logging.WithQueueKey(logger, queueKey).V(4).Info("queuing resource")
c.queue.Add(queueKey)
}

Expand Down Expand Up @@ -138,7 +138,7 @@ func (c *resourceController) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *resourceController) reconcile(ctx context.Context, obj *unstructured.Un

if err != nil {
if apierrors.IsNotFound(err) {
logger.V(2).Info("got a not found error when trying to patch")
logger.V(3).Info("got a not found error when trying to patch")
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (r *reconciler) reconcile(ctx context.Context, crb *rbacv1.ClusterRoleBindi
} else {
var changed bool
if crb.Annotations, changed = kcpcorehelper.DontReplicateFor(crb.Annotations, r.groupName); changed {
logger.V(2).Info("Not replicating ClusterRoleBinding")
logger.V(3).Info("Not replicating ClusterRoleBinding")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (r *reconciler) reconcile(ctx context.Context, cr *rbacv1.ClusterRole) (boo
} else {
var changed bool
if cr.Annotations, changed = kcpcorehelper.DontReplicateFor(cr.Annotations, r.groupName); changed {
logger.V(2).Info("Not replicating ClusterRole")
logger.V(3).Info("Not replicating ClusterRole")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (r *reconciler) reconcile(ctx context.Context, cluster *corev1alpha1.Logica
} else {
var changed bool
if cluster.Annotations, changed = kcpcorehelper.DontReplicateFor(cluster.Annotations, r.groupName); changed {
logger.V(2).Info("Not replicating LogicalCluster")
logger.V(3).Info("Not replicating LogicalCluster")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *Controller) enqueue(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing LogicalCluster")
logger.V(4).Info("queueing LogicalCluster")
c.queue.Add(key)
}

Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (c *Controller) process(ctx context.Context, key string) error {
}
logicalCluster, deleteErr := c.logicalClusterLister.Cluster(clusterName).Get(name)
if apierrors.IsNotFound(deleteErr) {
logger.V(2).Info("Workspace has been deleted")
logger.V(3).Info("Workspace has been deleted")
return nil
}
if deleteErr != nil {
Expand All @@ -258,7 +258,7 @@ func (c *Controller) process(ctx context.Context, key string) error {
startTime := time.Now()
deleteErr = c.deleter.Delete(ctx, logicalClusterCopy)
if deleteErr == nil {
logger.V(2).Info("finished deleting logical cluster content", "duration", time.Since(startTime))
logger.V(4).Info("finished deleting logical cluster content", "duration", time.Since(startTime))
return c.finalizeWorkspace(ctx, logicalClusterCopy)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/core/shard/shard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *Controller) enqueue(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing Shard")
logger.V(4).Info("queueing Shard")
c.queue.Add(key)
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (c *Controller) enqueue(obj interface{}) {
}

logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing LogicalCluster")
logger.V(4).Info("queueing LogicalCluster")
c.queue.Add(key)
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/kubequota/kubequota_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (c *Controller) enqueue(obj interface{}) {
}

logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing Workspace")
logger.V(4).Info("queueing Workspace")
c.queue.Add(key)
}

Expand Down Expand Up @@ -172,7 +172,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/tenancy/bootstrap/bootstrap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *controller) enqueue(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), c.controllerName), key)
logger.V(2).Info("queueing LogicalCluster")
logger.V(4).Info("queueing LogicalCluster")
c.queue.Add(key)
}

Expand Down Expand Up @@ -154,7 +154,7 @@ func (c *controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

if err := c.process(ctx, key); err != nil {
runtime.HandleError(fmt.Errorf("%q controller failed to sync %q, err: %w", c.controllerName, key, err))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (b *APIBinder) enqueueLogicalCluster(obj interface{}, logger logr.Logger) {
return
}

logging.WithQueueKey(logger, key).V(2).Info("queueing LogicalCluster")
logging.WithQueueKey(logger, key).V(4).Info("queueing LogicalCluster")
b.queue.Add(key)
}

Expand Down Expand Up @@ -265,7 +265,7 @@ func (b *APIBinder) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (b *APIBinder) reconcile(ctx context.Context, logicalCluster *corev1alpha1.

var errors []error
clusterName := logicalcluster.From(logicalCluster)
logger.V(2).Info("initializing APIBindings for workspace")
logger.V(3).Info("initializing APIBindings for workspace")

// Start with the WorkspaceType specified by the Workspace
leafWT, err := b.getWorkspaceType(wtCluster, wtName)
Expand Down Expand Up @@ -119,7 +119,7 @@ func (b *APIBinder) reconcile(ctx context.Context, logicalCluster *corev1alpha1.

for _, wt := range wts {
logger := logging.WithObject(logger, wt)
logger.V(2).Info("attempting to initialize APIBindings")
logger.V(3).Info("attempting to initialize APIBindings")

for i := range wt.Spec.DefaultAPIBindings {
exportRef := wt.Spec.DefaultAPIBindings[i]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (c *Controller) enqueue(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing LogicalCluster")
logger.V(4).Info("queueing LogicalCluster")
c.queue.Add(key)
}

Expand All @@ -120,7 +120,7 @@ func (c *Controller) enqueueCRB(obj interface{}) {
return
}
logger := logging.WithQueueKey(logging.WithReconciler(klog.Background(), ControllerName), key)
logger.V(2).Info("queueing LogicalCluster")
logger.V(4).Info("queueing LogicalCluster")
c.queue.Add(key)
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func (c *Controller) processNextWorkItem(ctx context.Context) bool {

logger := logging.WithQueueKey(klog.FromContext(ctx), key)
ctx = klog.NewContext(ctx, logger)
logger.V(1).Info("processing key")
logger.V(4).Info("processing key")

// No matter what, tell the queue we're done with this key, to unblock
// other workers.
Expand Down
Loading