diff --git a/pkg/k8sclient/k8sclient.go b/pkg/k8sclient/k8sclient.go index 67f84135..80029a64 100644 --- a/pkg/k8sclient/k8sclient.go +++ b/pkg/k8sclient/k8sclient.go @@ -143,6 +143,8 @@ func WritePodAnnotation(kubeClient kubernetes.Interface, pod *v1.Pod) (*v1.Pod, return pod, logging.Errorf("WritePodAnnotation: No pod: %v", err) } + // Keep original pod info for log message in case of failure + origPod := pod // Update the pod pod = pod.DeepCopy() if resultErr := retry.RetryOnConflict(retry.DefaultBackoff, func() error { @@ -157,7 +159,7 @@ func WritePodAnnotation(kubeClient kubernetes.Interface, pod *v1.Pod) (*v1.Pod, pod, err = kubeClient.CoreV1().Pods(pod.Namespace).UpdateStatus(pod) return err }); resultErr != nil { - return nil, logging.Errorf("status update failed for pod %s/%s: %v", pod.Namespace, pod.Name, resultErr) + return nil, logging.Errorf("status update failed for pod %s/%s: %v", origPod.Namespace, origPod.Name, resultErr) } return pod, nil }