@@ -139,13 +139,13 @@ func (c *FHPAController) SetupWithManager(mgr controllerruntime.Manager) error {
139
139
// The Controller will requeue the Request to be processed again if an error is non-nil or
140
140
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
141
141
func (c * FHPAController ) Reconcile (ctx context.Context , req controllerruntime.Request ) (controllerruntime.Result , error ) {
142
- klog .V (4 ).Infof ("Reconciling FederatedHPA %s. " , req .NamespacedName .String ())
142
+ klog .V (4 ).InfoS ("Reconciling FederatedHPA" , "namespacedName " , req .NamespacedName .String ())
143
143
144
144
hpa := & autoscalingv1alpha1.FederatedHPA {}
145
145
key := req .NamespacedName .String ()
146
146
if err := c .Client .Get (ctx , req .NamespacedName , hpa ); err != nil {
147
147
if apierrors .IsNotFound (err ) {
148
- klog .Infof ("FederatedHPA %s has been deleted in %s " , req .Name , req .Namespace )
148
+ klog .InfoS ("FederatedHPA has been deleted in namespace " , "hpaName" , req .Name , "namespace" , req .Namespace )
149
149
c .recommendationsLock .Lock ()
150
150
delete (c .recommendations , key )
151
151
c .recommendationsLock .Unlock ()
@@ -344,7 +344,7 @@ func (c *FHPAController) reconcileAutoscaler(ctx context.Context, hpa *autoscali
344
344
retErr = err
345
345
}
346
346
347
- klog .V (4 ).Infof ("proposing %v desired replicas (based on %s from %s) for %s " , metricDesiredReplicas , metricName , metricTimestamp , reference )
347
+ klog .V (4 ).InfoS ("proposing desired replicas for resource " , "desiredReplicas" , metricDesiredReplicas , " metricName" , metricName , " metricTimestamp" , metricTimestamp , "resource" , reference )
348
348
349
349
rescaleMetric := ""
350
350
if metricDesiredReplicas > desiredReplicas {
@@ -382,16 +382,16 @@ func (c *FHPAController) reconcileAutoscaler(ctx context.Context, hpa *autoscali
382
382
setCondition (hpa , autoscalingv2 .AbleToScale , corev1 .ConditionTrue , "SucceededRescale" , "the HPA controller was able to update the target scale to %d" , desiredReplicas )
383
383
c .EventRecorder .Eventf (hpa , corev1 .EventTypeNormal , "SuccessfulRescale" , "New size: %d; reason: %s" , desiredReplicas , rescaleReason )
384
384
c .storeScaleEvent (hpa .Spec .Behavior , key , currentReplicas , desiredReplicas )
385
- klog .Infof ( "Successful rescale of %s, old size: %d, new size: %d, reason: %s " ,
386
- hpa .Name , currentReplicas , desiredReplicas , rescaleReason )
385
+ klog .InfoS ( "Successfully rescaled FederatedHPA " ,
386
+ "hpaName" , hpa .Name , " currentReplicas" , currentReplicas , " desiredReplicas" , desiredReplicas , "rescaleReason" , rescaleReason )
387
387
388
388
if desiredReplicas > currentReplicas {
389
389
actionLabel = monitor .ActionLabelScaleUp
390
390
} else {
391
391
actionLabel = monitor .ActionLabelScaleDown
392
392
}
393
393
} else {
394
- klog .V (4 ).Infof ("decided not to scale %s to %v (last scale time was %s)" , reference , desiredReplicas , hpa .Status .LastScaleTime )
394
+ klog .V (4 ).InfoS ("decided not to scale resource" , "resource" , reference , " desiredReplicas" , desiredReplicas , "hpaLastScaleTime" , hpa .Status .LastScaleTime )
395
395
desiredReplicas = currentReplicas
396
396
}
397
397
@@ -484,19 +484,19 @@ func (c *FHPAController) scaleForTargetCluster(ctx context.Context, clusters []s
484
484
for _ , cluster := range clusters {
485
485
clusterClient , err := c .ClusterScaleClientSetFunc (cluster , c .Client )
486
486
if err != nil {
487
- klog .Errorf ( "Failed to get cluster client of cluster %s. " , cluster )
487
+ klog .ErrorS ( err , "Failed to get cluster client of cluster" , "cluster " , cluster )
488
488
continue
489
489
}
490
490
491
491
clusterInformerManager , err := c .buildPodInformerForCluster (clusterClient )
492
492
if err != nil {
493
- klog .Errorf ( "Failed to get or create informer for cluster %s. Error: %v. " , cluster , err )
493
+ klog .ErrorS ( err , "Failed to get or create informer for cluster" , " cluster" , cluster )
494
494
continue
495
495
}
496
496
497
497
scale , err := clusterClient .ScaleClient .Scales (hpa .Namespace ).Get (ctx , targetGR , hpa .Spec .ScaleTargetRef .Name , metav1.GetOptions {})
498
498
if err != nil {
499
- klog .Errorf ( "Failed to get scale subResource of resource %s in cluster %s." , hpa .Spec .ScaleTargetRef .Name , cluster )
499
+ klog .ErrorS ( err , "Failed to get scale subResource of resource in cluster" , "resource" , hpa .Spec .ScaleTargetRef .Name , "cluster" , cluster )
500
500
continue
501
501
}
502
502
@@ -523,19 +523,19 @@ func (c *FHPAController) scaleForTargetCluster(ctx context.Context, clusters []s
523
523
524
524
podInterface , err := clusterInformerManager .Lister (podGVR )
525
525
if err != nil {
526
- klog .Errorf ( "Failed to get podInterface for cluster %s. " , cluster )
526
+ klog .ErrorS ( err , "Failed to get podInterface for cluster" , "cluster " , cluster )
527
527
continue
528
528
}
529
529
530
530
podLister , ok := podInterface .(listcorev1.PodLister )
531
531
if ! ok {
532
- klog .Errorf ( "Failed to convert interface to PodLister for cluster %s. " , cluster )
532
+ klog .ErrorS ( nil , "Failed to convert interface to PodLister for cluster" , "cluster " , cluster )
533
533
continue
534
534
}
535
535
536
536
podList , err := podLister .Pods (hpa .Namespace ).List (selector )
537
537
if err != nil {
538
- klog .Errorf ( "Failed to get podList for cluster %s. " , cluster )
538
+ klog .ErrorS ( err , "Failed to get podList for cluster" , "cluster " , cluster )
539
539
continue
540
540
}
541
541
@@ -561,7 +561,7 @@ func (c *FHPAController) buildPodInformerForCluster(clusterScaleClient *util.Clu
561
561
}
562
562
563
563
if _ , err := singleClusterInformerManager .Lister (podGVR ); err != nil {
564
- klog .Errorf ( "Failed to get the lister for pods: %v" , err )
564
+ klog .ErrorS ( err , "Failed to get the lister for pods" )
565
565
}
566
566
567
567
c .TypedInformerManager .Start (clusterScaleClient .ClusterName )
@@ -576,7 +576,7 @@ func (c *FHPAController) buildPodInformerForCluster(clusterScaleClient *util.Clu
576
576
}
577
577
return nil
578
578
}(); err != nil {
579
- klog .Errorf ( "Failed to sync cache for cluster: %s, error: %v" , clusterScaleClient .ClusterName , err )
579
+ klog .ErrorS ( err , "Failed to sync cache for cluster" , "cluster" , clusterScaleClient .ClusterName )
580
580
c .TypedInformerManager .Stop (clusterScaleClient .ClusterName )
581
581
return nil , err
582
582
}
@@ -1377,7 +1377,7 @@ func (c *FHPAController) updateStatus(ctx context.Context, hpa *autoscalingv1alp
1377
1377
c .EventRecorder .Event (hpa , corev1 .EventTypeWarning , "FailedUpdateStatus" , err .Error ())
1378
1378
return fmt .Errorf ("failed to update status for %s: %v" , hpa .Name , err )
1379
1379
}
1380
- klog .V (2 ).Infof ("Successfully updated status for %s " , hpa .Name )
1380
+ klog .V (2 ).InfoS ("Successfully updated status for hpa" , "hpaName " , hpa .Name )
1381
1381
return nil
1382
1382
}
1383
1383
0 commit comments