Merge pull request #109694 from RyanAoh/fix-108837
Be sure to update the status of StatefulSet even if the new replica creation fails
This commit is contained in:
@@ -109,16 +109,6 @@ func (ssc *defaultStatefulSetControl) performUpdate(
|
||||
if err != nil {
|
||||
return currentRevision, updateRevision, currentStatus, err
|
||||
}
|
||||
// update the set's status
|
||||
err = ssc.updateStatefulSetStatus(ctx, set, currentStatus)
|
||||
if err != nil {
|
||||
return currentRevision, updateRevision, currentStatus, err
|
||||
}
|
||||
klog.V(4).InfoS("StatefulSet pod status", "statefulSet", klog.KObj(set),
|
||||
"replicas", currentStatus.Replicas,
|
||||
"readyReplicas", currentStatus.ReadyReplicas,
|
||||
"currentReplicas", currentStatus.CurrentReplicas,
|
||||
"updatedReplicas", currentStatus.UpdatedReplicas)
|
||||
|
||||
klog.V(4).InfoS("StatefulSet revisions", "statefulSet", klog.KObj(set),
|
||||
"currentRevision", currentStatus.CurrentRevision,
|
||||
@@ -274,7 +264,7 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
currentRevision *apps.ControllerRevision,
|
||||
updateRevision *apps.ControllerRevision,
|
||||
collisionCount int32,
|
||||
pods []*v1.Pod) (*apps.StatefulSetStatus, error) {
|
||||
pods []*v1.Pod) (statefulSetStatus *apps.StatefulSetStatus, updateErr error) {
|
||||
// get the current and update revisions of the set.
|
||||
currentSet, err := ApplyRevision(set, currentRevision)
|
||||
if err != nil {
|
||||
@@ -340,6 +330,23 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
// If the ordinal could not be parsed (ord < 0), ignore the Pod.
|
||||
}
|
||||
|
||||
// make sure to update the latest status even if there is an error later
|
||||
defer func() {
|
||||
// update the set's status
|
||||
statusErr := ssc.updateStatefulSetStatus(ctx, set, &status)
|
||||
if statusErr == nil {
|
||||
klog.V(4).InfoS("Updated status", "statefulSet", klog.KObj(set),
|
||||
"replicas", status.Replicas,
|
||||
"readyReplicas", status.ReadyReplicas,
|
||||
"currentReplicas", status.CurrentReplicas,
|
||||
"updatedReplicas", status.UpdatedReplicas)
|
||||
} else if updateErr == nil {
|
||||
updateErr = statusErr
|
||||
} else {
|
||||
klog.V(4).InfoS("Could not update status", "statefulSet", klog.KObj(set), "err", statusErr)
|
||||
}
|
||||
}()
|
||||
|
||||
// for any empty indices in the sequence [0,set.Spec.Replicas) create a new Pod at the correct revision
|
||||
for ord := 0; ord < replicaCount; ord++ {
|
||||
if replicas[ord] == nil {
|
||||
|
Reference in New Issue
Block a user