Skip to content

Commit

Permalink
Update log level for few messages in PodAutoscaler (#612)
Browse files Browse the repository at this point in the history
Update log level for few messages in pod autoscaler
  • Loading branch information
varungup90 authored Jan 27, 2025
1 parent 646904b commit c6853ad
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pkg/controller/podautoscaler/metrics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (c *KPAMetricsClient) UpdateMetrics(now time.Time, metricKey NamespaceNameM
if err != nil {
return err
}
klog.InfoS("Update pod list metrics", "metricKey", metricKey, "valueNum", len(metricValues), "timestamp", now, "metricValue", sumMetricValue)
klog.V(4).InfoS("Update pod list metrics", "metricKey", metricKey, "valueNum", len(metricValues), "timestamp", now, "metricValue", sumMetricValue)
return nil
}

Expand All @@ -116,14 +116,14 @@ func (c *KPAMetricsClient) StableAndPanicMetrics(
return -1, -1, err
}

klog.InfoS("Get panicWindow", "metricKey", metricKey, "panicValue", panicValue, "panicWindow", c.panicWindow)
klog.V(4).InfoS("Get panicWindow", "metricKey", metricKey, "panicValue", panicValue, "panicWindow", c.panicWindow)

stableValue, err := c.stableWindow.Avg()
if err != nil {
return -1, -1, err
}

klog.Infof("Get stableWindow: metricKey=%s, stableValue=%.2f, stableWindow=%v", metricKey, stableValue, c.stableWindow)
klog.V(4).Infof("Get stableWindow: metricKey=%s, stableValue=%.2f, stableWindow=%v", metricKey, stableValue, c.stableWindow)
return stableValue, panicValue, nil
}

Expand Down Expand Up @@ -195,7 +195,7 @@ func (c *APAMetricsClient) UpdateMetrics(now time.Time, metricKey NamespaceNameM
if err != nil {
return err
}
klog.InfoS("Update pod list metrics", "metricKey", metricKey, "valueNum", len(metricValues), "timestamp", now, "metricValue", sumMetricValue)
klog.V(4).InfoS("Update pod list metrics", "metricKey", metricKey, "valueNum", len(metricValues), "timestamp", now, "metricValue", sumMetricValue)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/podautoscaler/metrics/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (f *RestMetricsFetcher) FetchMetric(ctx context.Context, protocol autoscali
defer func() {
if err := resp.Body.Close(); err != nil {
// Handle the error here. For example, log it or take appropriate corrective action.
klog.InfoS("Error closing response body:", err)
klog.ErrorS(err, "error closing response body")
}
}()
body, err := io.ReadAll(resp.Body)
Expand All @@ -119,7 +119,7 @@ func (f *RestMetricsFetcher) FetchMetric(ctx context.Context, protocol autoscali
return 0.0, fmt.Errorf("failed to parse metrics from source %s: %v", url, err)
}

klog.InfoS("Successfully parsed metrics", "metric", metricName, "source", url, "metricValue", metricValue)
klog.V(4).InfoS("Successfully parsed metrics", "metric", metricName, "source", url, "metricValue", metricValue)

return metricValue, nil
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/podautoscaler/podautoscaler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func (r *PodAutoscalerReconciler) reconcileCustomPA(ctx context.Context, pa auto
return ctrl.Result{}, fmt.Errorf("failed to compute desired number of replicas based on listed metrics for %s: %v", scaleReference, err)
}

klog.InfoS("Proposing desired replicas",
klog.V(4).InfoS("Proposing desired replicas",
"desiredReplicas", metricDesiredReplicas,
"metric", metricName,
"timestamp", metricTimestamp,
Expand All @@ -450,11 +450,11 @@ func (r *PodAutoscalerReconciler) reconcileCustomPA(ctx context.Context, pa auto

// adjust desired metrics within the <min, max> range
if desiredReplicas > pa.Spec.MaxReplicas {
klog.InfoS("Scaling adjustment: Algorithm recommended scaling to a target that exceeded the maximum limit.",
klog.V(2).InfoS("Scaling adjustment: Algorithm recommended scaling to a target that exceeded the maximum limit.",
"recommendedReplicas", desiredReplicas, "adjustedTo", pa.Spec.MaxReplicas)
desiredReplicas = pa.Spec.MaxReplicas
} else if desiredReplicas < minReplicas {
klog.InfoS("Scaling adjustment: Algorithm recommended scaling to a target that fell below the minimum limit.",
klog.V(2).InfoS("Scaling adjustment: Algorithm recommended scaling to a target that fell below the minimum limit.",
"recommendedReplicas", desiredReplicas, "adjustedTo", minReplicas)
desiredReplicas = minReplicas
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/podautoscaler/scaler/kpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (k *KpaAutoscaler) Scale(originalReadyPodsCount int, metricKey metrics.Name
}
desiredPodCount = k.maxPanicPods
} else {
klog.InfoS("Operating in stable mode.", "desiredPodCount", desiredPodCount)
klog.V(4).InfoS("Operating in stable mode.", "desiredPodCount", desiredPodCount)
}

// Delay scale down decisions, if a ScaleDownDelay was specified.
Expand Down

0 comments on commit c6853ad

Please sign in to comment.