Skip to content

Commit

Permalink
Use klog.KRef wherever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
ialidzhikov committed Jun 19, 2024
1 parent 628fc39 commit 1739a71
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func getVpasToCheckpoint(clusterVpas map[model.VpaID]*model.Vpa) []*model.Vpa {
vpas := make([]*model.Vpa, 0, len(clusterVpas))
for _, vpa := range clusterVpas {
if isFetchingHistory(vpa) {
klog.V(3).Infof("VPA %s/%s is loading history, skipping checkpoints", vpa.ID.Namespace, vpa.ID.VpaName)
klog.V(3).Infof("VPA %s is loading history, skipping checkpoints", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName))
continue
}
vpas = append(vpas, vpa)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ func (feeder *clusterStateFeeder) LoadVPAs() {
// Delete non-existent VPAs from the model.
for vpaID := range feeder.clusterState.Vpas {
if _, exists := vpaKeys[vpaID]; !exists {
klog.V(3).Infof("Deleting VPA %s/%s", vpaID.Namespace, vpaID.VpaName)
klog.V(3).Infof("Deleting VPA %s", klog.KRef(vpaID.Namespace, vpaID.VpaName))
if err := feeder.clusterState.DeleteVpa(vpaID); err != nil {
klog.Errorf("Deleting VPA %s/%s failed: %v", vpaID.Namespace, vpaID.VpaName, err)
klog.Errorf("Deleting VPA %s failed: %v", klog.KRef(vpaID.Namespace, vpaID.VpaName), err)
}
}
}
Expand All @@ -398,7 +398,7 @@ func (feeder *clusterStateFeeder) LoadPods() {
}
for key := range feeder.clusterState.Pods {
if _, exists := pods[key]; !exists {
klog.V(3).Infof("Deleting Pod %s/%s", key.Namespace, key.PodName)
klog.V(3).Infof("Deleting Pod %s", klog.KRef(key.Namespace, key.PodName))
feeder.clusterState.DeletePod(key)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ func (s *externalMetricsClient) List(ctx context.Context, namespace string, opts
return nil, err
}
if m == nil || len(m.Items) == 0 {
klog.V(4).Infof("External Metrics Query for VPA %s/%s: resource %+v, metric %+v, No items,", vpa.ID.Namespace, vpa.ID.VpaName, resourceName, metricName)
klog.V(4).Infof("External Metrics Query for VPA %s: resource %+v, metric %+v, No items,", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), resourceName, metricName)
continue
}
klog.V(4).Infof("External Metrics Query for VPA %s/%s: resource %+v, metric %+v, %d items, item[0]: %+v", vpa.ID.Namespace, vpa.ID.VpaName, resourceName, metricName, len(m.Items), m.Items[0])
klog.V(4).Infof("External Metrics Query for VPA %s: resource %+v, metric %+v, %d items, item[0]: %+v", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), resourceName, metricName, len(m.Items), m.Items[0])
podMets.Timestamp = m.Items[0].Timestamp
if m.Items[0].WindowSeconds != nil {
podMets.Window = v1.Duration{Duration: time.Duration(*m.Items[0].WindowSeconds) * time.Second}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (r *recommender) UpdateVPAs() {
pods := r.clusterState.GetMatchingPods(vpa)
klog.Infof("MatchingPods: %+v", pods)
if len(pods) != vpa.PodCount {
klog.Errorf("ClusterState pod count and matching pods disagree for VPA %s/%s", vpa.ID.Namespace, vpa.ID.VpaName)
klog.Errorf("ClusterState pod count and matching pods disagree for VPA %s", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName))
}
}
}
Expand All @@ -126,7 +126,7 @@ func (r *recommender) UpdateVPAs() {
r.vpaClient.VerticalPodAutoscalers(vpa.ID.Namespace), vpa.ID.VpaName, vpa.AsStatus(), &observedVpa.Status)
if err != nil {
klog.Errorf(
"Cannot update VPA %s/%s object. Reason: %+v", vpa.ID.Namespace, vpa.ID.VpaName, err)
"Cannot update VPA %s object. Reason: %+v", klog.KRef(vpa.ID.Namespace, vpa.ID.VpaName), err)
}
}
}
Expand Down

0 comments on commit 1739a71

Please sign in to comment.