Skip to content

Commit f5ee2ce

Browse files
authored
Merge pull request #6555 from mohit-nagaraj/master
refactor(app): improve logging in graceful eviction controllers
2 parents 140f745 + b1138ed commit f5ee2ce

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

pkg/controllers/gracefuleviction/crb_graceful_eviction_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type CRBGracefulEvictionController struct {
5252
// The Controller will requeue the Request to be processed again if an error is non-nil or
5353
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
5454
func (c *CRBGracefulEvictionController) Reconcile(ctx context.Context, req controllerruntime.Request) (controllerruntime.Result, error) {
55-
klog.V(4).Infof("Reconciling ClusterResourceBinding %s.", req.NamespacedName.String())
55+
klog.V(4).InfoS("Reconciling ClusterResourceBinding", "name", req.NamespacedName.String())
5656

5757
binding := &workv1alpha2.ClusterResourceBinding{}
5858
if err := c.Client.Get(ctx, req.NamespacedName, binding); err != nil {
@@ -71,7 +71,7 @@ func (c *CRBGracefulEvictionController) Reconcile(ctx context.Context, req contr
7171
return controllerruntime.Result{}, err
7272
}
7373
if retryDuration > 0 {
74-
klog.V(4).Infof("Retry to evict task after %v minutes.", retryDuration.Minutes())
74+
klog.V(4).InfoS("Retry to evict task after minutes", "retryAfterMinutes", retryDuration.Minutes())
7575
return controllerruntime.Result{RequeueAfter: retryDuration}, nil
7676
}
7777
return controllerruntime.Result{}, nil
@@ -97,8 +97,8 @@ func (c *CRBGracefulEvictionController) syncBinding(ctx context.Context, binding
9797
}
9898

9999
for _, cluster := range evictedClusters {
100-
klog.V(2).Infof("Success to evict Cluster(%s) from ClusterResourceBinding(%s) gracefulEvictionTasks",
101-
cluster, binding.Name)
100+
klog.V(2).InfoS("Evicted cluster from ClusterResourceBinding gracefulEvictionTasks",
101+
"cluster", cluster, "name", binding.Name)
102102
helper.EmitClusterEvictionEventForClusterResourceBinding(binding, cluster, c.EventRecorder, err)
103103
}
104104
return nextRetry(keptTask, c.GracefulEvictionTimeout, metav1.Now().Time), nil

pkg/controllers/gracefuleviction/rb_graceful_eviction_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type RBGracefulEvictionController struct {
5252
// The Controller will requeue the Request to be processed again if an error is non-nil or
5353
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
5454
func (c *RBGracefulEvictionController) Reconcile(ctx context.Context, req controllerruntime.Request) (controllerruntime.Result, error) {
55-
klog.V(4).Infof("Reconciling ResourceBinding %s.", req.NamespacedName.String())
55+
klog.V(4).InfoS("Reconciling ResourceBinding", "namespace", req.Namespace, "name", req.Name)
5656

5757
binding := &workv1alpha2.ResourceBinding{}
5858
if err := c.Client.Get(ctx, req.NamespacedName, binding); err != nil {
@@ -71,7 +71,7 @@ func (c *RBGracefulEvictionController) Reconcile(ctx context.Context, req contro
7171
return controllerruntime.Result{}, err
7272
}
7373
if retryDuration > 0 {
74-
klog.V(4).Infof("Retry to evict task after %v minutes.", retryDuration.Minutes())
74+
klog.V(4).InfoS("Retry to evict task after minutes", "retryAfterMinutes", retryDuration.Minutes())
7575
return controllerruntime.Result{RequeueAfter: retryDuration}, nil
7676
}
7777
return controllerruntime.Result{}, nil
@@ -97,8 +97,8 @@ func (c *RBGracefulEvictionController) syncBinding(ctx context.Context, binding
9797
}
9898

9999
for _, cluster := range evictedCluster {
100-
klog.V(2).Infof("Success to evict Cluster(%s) from ResourceBinding(%s/%s) gracefulEvictionTasks",
101-
cluster, binding.Namespace, binding.Name)
100+
klog.V(2).InfoS("Evicted cluster from ResourceBinding gracefulEvictionTasks", "cluster", cluster,
101+
"namespace", binding.Namespace, "name", binding.Name)
102102
helper.EmitClusterEvictionEventForResourceBinding(binding, cluster, c.EventRecorder, err)
103103
}
104104
return nextRetry(keptTask, c.GracefulEvictionTimeout, metav1.Now().Time), nil

0 commit comments

Comments
 (0)