Skip to content

Commit

Permalink
Merge pull request #50 from przemeklal/fix_null_pointer_k8sclient
Browse files Browse the repository at this point in the history
Fix error handling in k8sclient
  • Loading branch information
garyloug authored Oct 14, 2020
2 parents 0b9661a + e69d0b3 commit 883ddd0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/k8sclient/k8sclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

0 comments on commit 883ddd0

Please sign in to comment.