Merge pull request #5738 from smarterclayton/cleanup_clients

Clients should not check conditions, UpdateStatus() is inconsistent
This commit is contained in:
Yu-Ju Hong
2015-03-25 13:59:47 -07:00
19 changed files with 32 additions and 163 deletions

View File

@@ -106,16 +106,26 @@ func (s *statusManager) syncBatch() error {
podFullName := kubecontainer.GetPodFullName(pod)
status := syncRequest.status
_, err := s.kubeClient.Pods(pod.Namespace).UpdateStatus(pod.Name, &status)
var err error
statusPod := &api.Pod{
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
}
if err == nil {
statusPod, 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)
} else {
glog.V(3).Infof("Status for pod %q updated successfully", pod.Name)
}
glog.V(3).Infof("Status for pod %q updated successfully", pod.Name)
return nil
}

View File

@@ -110,5 +110,5 @@ func TestSyncBatch(t *testing.T) {
if err != nil {
t.Errorf("unexpected syncing error: %v", err)
}
verifyActions(t, syncer.kubeClient, []string{"update-status-pod"})
verifyActions(t, syncer.kubeClient, []string{"get-pod", "update-status-pod"})
}