diff --git a/pkg/kubelet/status_manager.go b/pkg/kubelet/status_manager.go index f5a80e89954..fb8ac93a797 100644 --- a/pkg/kubelet/status_manager.go +++ b/pkg/kubelet/status_manager.go @@ -112,21 +112,20 @@ func (s *statusManager) syncBatch() error { ObjectMeta: pod.ObjectMeta, } // TODO: make me easier to express from client code - if statusPod, err = s.kubeClient.Pods(statusPod.Namespace).Get(statusPod.Name); err == nil { - statusPod.Status = status - } + statusPod, err = s.kubeClient.Pods(statusPod.Namespace).Get(statusPod.Name) if err == nil { - statusPod, err = s.kubeClient.Pods(pod.Namespace).UpdateStatus(statusPod) + statusPod.Status = status + _, err = s.kubeClient.Pods(pod.Namespace).UpdateStatus(statusPod) // TODO: handle conflict as a retry, make that easier too. - } - if err != nil { - // We failed to update status. In order to make sure we retry next time - // we delete cached value. This may result in an additional update, but - // this is ok. - s.DeletePodStatus(podFullName) - return fmt.Errorf("error updating status for pod %q: %v", pod.Name, err) + if err == nil { + glog.V(3).Infof("Status for pod %q updated successfully", pod.Name) + return nil + } } - glog.V(3).Infof("Status for pod %q updated successfully", pod.Name) - return nil + // We failed to update status. In order to make sure we retry next time + // we delete cached value. This may result in an additional update, but + // this is ok. + s.DeletePodStatus(podFullName) + return fmt.Errorf("error updating status for pod %q: %v", pod.Name, err) }