diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/handler.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/handler.go index d43fd08edd42..20d7549e5c34 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/handler.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/handler.go @@ -76,10 +76,10 @@ func (h *resourceHandler) GetPatches(ar *admissionv1.AdmissionRequest) ([]resour pod.Name = pod.GenerateName + "%" pod.Namespace = namespace } - klog.V(4).Infof("Admitting pod %v", pod.ObjectMeta) + klog.V(4).Infof("Admitting pod %s", klog.KObj(&pod)) controllingVpa := h.vpaMatcher.GetMatchingVPA(&pod) if controllingVpa == nil { - klog.V(4).Infof("No matching VPA found for pod %s/%s", pod.Namespace, pod.Name) + klog.V(4).Infof("No matching VPA found for pod %s", klog.KObj(&pod)) return []resource_admission.PatchRecord{}, nil } pod, err := h.preProcessor.Process(pod) diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/patch/resource_updates.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/patch/resource_updates.go index bed6119900ba..cddec1aa83fb 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/patch/resource_updates.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/patch/resource_updates.go @@ -51,7 +51,7 @@ func (c *resourcesUpdatesPatchCalculator) CalculatePatches(pod *core.Pod, vpa *v containersResources, annotationsPerContainer, err := c.recommendationProvider.GetContainersResourcesForPod(pod, vpa) if err != nil { - return []resource_admission.PatchRecord{}, fmt.Errorf("Failed to calculate resource patch for pod %v/%v: %v", pod.Namespace, pod.Name, err) + return []resource_admission.PatchRecord{}, fmt.Errorf("Failed to calculate resource patch for pod %s/%s: %v", pod.Namespace, pod.Name, err) } if annotationsPerContainer == nil { diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/recommendation/recommendation_provider.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/recommendation/recommendation_provider.go index 3522f1b5ae91..3272058e3e5d 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/recommendation/recommendation_provider.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/pod/recommendation/recommendation_provider.go @@ -97,7 +97,7 @@ func (p *recommendationProvider) GetContainersResourcesForPod(pod *core.Pod, vpa var err error recommendedPodResources, annotations, err = p.recommendationProcessor.Apply(vpa.Status.Recommendation, vpa.Spec.ResourcePolicy, vpa.Status.Conditions, pod) if err != nil { - klog.V(2).Infof("cannot process recommendation for pod %s", pod.Name) + klog.V(2).Infof("cannot process recommendation for pod %s", klog.KObj(pod)) return nil, annotations, err } } @@ -114,7 +114,7 @@ func (p *recommendationProvider) GetContainersResourcesForPod(pod *core.Pod, vpa // Ensure that we are not propagating empty resource key if any. for _, resource := range containerResources { if resource.RemoveEmptyResourceKeyIfAny() { - klog.Infof("An empty resource key was found and purged for pod=%s/%s with vpa=", pod.Namespace, pod.Name, vpa.Name) + klog.Infof("An empty resource key was found and purged for pod=%s with vpa=%s", klog.KObj(pod), klog.KObj(vpa)) } } diff --git a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go index 8c74638333d6..cee7c97859ff 100644 --- a/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go +++ b/vertical-pod-autoscaler/pkg/admission-controller/resource/vpa/matcher.go @@ -62,7 +62,7 @@ func (m *matcher) GetMatchingVPA(pod *core.Pod) *vpa_types.VerticalPodAutoscaler } selector, err := m.selectorFetcher.Fetch(vpaConfig) if err != nil { - klog.V(3).Infof("skipping VPA object %v because we cannot fetch selector: %s", vpaConfig.Name, err) + klog.V(3).Infof("skipping VPA object %s because we cannot fetch selector: %s", klog.KObj(vpaConfig), err) continue } onConfigs = append(onConfigs, &vpa_api_util.VpaWithSelector{ @@ -70,7 +70,7 @@ func (m *matcher) GetMatchingVPA(pod *core.Pod) *vpa_types.VerticalPodAutoscaler Selector: selector, }) } - klog.V(2).Infof("Let's choose from %d configs for pod %s/%s", len(onConfigs), pod.Namespace, pod.Name) + klog.V(2).Infof("Let's choose from %d configs for pod %s", len(onConfigs), klog.KObj(pod)) result := vpa_api_util.GetControllingVPAForPod(pod, onConfigs, m.controllerFetcher) if result != nil { return result.Vpa diff --git a/vertical-pod-autoscaler/pkg/utils/vpa/api.go b/vertical-pod-autoscaler/pkg/utils/vpa/api.go index 529d76961727..42fa0bb54d27 100644 --- a/vertical-pod-autoscaler/pkg/utils/vpa/api.go +++ b/vertical-pod-autoscaler/pkg/utils/vpa/api.go @@ -150,7 +150,7 @@ func GetControllingVPAForPod(pod *core.Pod, vpas []*VpaWithSelector, ctrlFetcher } parentController, err := ctrlFetcher.FindTopMostWellKnownOrScalable(k) if err != nil { - klog.Errorf("fail to get pod controller: pod=%s err=%s", pod.Name, err.Error()) + klog.Errorf("fail to get pod controller: pod=%s err=%s", klog.KObj(pod), err.Error()) return nil } if parentController == nil { @@ -231,7 +231,7 @@ func CreateOrUpdateVpaCheckpoint(vpaCheckpointClient vpa_api.VerticalPodAutoscal _, err = vpaCheckpointClient.Create(context.TODO(), vpaCheckpoint, meta.CreateOptions{}) } if err != nil { - return fmt.Errorf("Cannot save checkpoint for vpa %v container %v. Reason: %+v", vpaCheckpoint.ObjectMeta.Name, vpaCheckpoint.Spec.ContainerName, err) + return fmt.Errorf("Cannot save checkpoint for vpa %s/%s container %s. Reason: %+v", vpaCheckpoint.Namespace, vpaCheckpoint.Name, vpaCheckpoint.Spec.ContainerName, err) } return nil }