Commit e2cec406 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #45002 from zhangxiaoyu-zidif/statefulset-format-err

Automatic merge from submit-queue stateful_pod_control.go: format the code **What this PR does / why we need it**: 1.Improve the quality of the code. 2.Reduce reduandant parameters 3.add one comma **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents ef4b4acf 026638af
......@@ -112,18 +112,17 @@ func (spc *realStatefulPodControl) UpdateStatefulPod(set *apps.StatefulSet, pod
return err
}
}
// if the Pod is not dirty do nothing
// if the Pod is not dirty, do nothing
if consistent {
return nil
}
attemptedUpdate = true
// commit the update, retrying on conflicts
_, err := spc.client.Core().Pods(set.Namespace).Update(pod)
if err == nil {
_, updateErr := spc.client.Core().Pods(set.Namespace).Update(pod)
if updateErr == nil {
return nil
}
updateErr := err
if updated, err := spc.podLister.Pods(set.Namespace).Get(pod.Name); err == nil {
// make a copy so we don't mutate the shared cache
......@@ -154,13 +153,11 @@ func (spc *realStatefulPodControl) UpdateStatefulSetStatus(set *apps.StatefulSet
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
set.Status.Replicas = replicas
set.Status.ObservedGeneration = &generation
_, err := spc.client.Apps().StatefulSets(set.Namespace).UpdateStatus(set)
if err == nil {
_, updateErr := spc.client.Apps().StatefulSets(set.Namespace).UpdateStatus(set)
if updateErr == nil {
return nil
}
updateErr := err
if updated, err := spc.setLister.StatefulSets(set.Namespace).Get(set.Name); err == nil {
// make a copy so we don't mutate the shared cache
if copy, err := scheme.Scheme.DeepCopy(updated); err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment