mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 13:14:05 +00:00
Merge pull request #5738 from smarterclayton/cleanup_clients
Clients should not check conditions, UpdateStatus() is inconsistent
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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"})
|
||||
}
|
||||
|
Reference in New Issue
Block a user