mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #62943 from faraazkhan/master
Automatic merge from submit-queue (batch tested with PRs 66304, 62943). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. set updated replicas **What this PR does / why we need it**: Sets the `.status.updatedReplicas` field for stateful sets when they are being created. This behavior is consistent with how this field is handled in the deployments controller and also allows for `kubectl rollout status` to work when stateful sets are being created. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #52653 **Special notes for your reviewer**: **Release note**: ```release-note fix rollout status for statefulsets ```
This commit is contained in:
commit
162655f42f
@ -297,7 +297,8 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
if isCreated(pods[i]) && !isTerminating(pods[i]) {
|
||||
if getPodRevision(pods[i]) == currentRevision.Name {
|
||||
status.CurrentReplicas++
|
||||
} else if getPodRevision(pods[i]) == updateRevision.Name {
|
||||
}
|
||||
if getPodRevision(pods[i]) == updateRevision.Name {
|
||||
status.UpdatedReplicas++
|
||||
}
|
||||
}
|
||||
@ -379,7 +380,8 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
}
|
||||
if getPodRevision(replicas[i]) == currentRevision.Name {
|
||||
status.CurrentReplicas--
|
||||
} else if getPodRevision(replicas[i]) == updateRevision.Name {
|
||||
}
|
||||
if getPodRevision(replicas[i]) == updateRevision.Name {
|
||||
status.UpdatedReplicas--
|
||||
}
|
||||
status.Replicas--
|
||||
@ -398,7 +400,8 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
status.Replicas++
|
||||
if getPodRevision(replicas[i]) == currentRevision.Name {
|
||||
status.CurrentReplicas++
|
||||
} else if getPodRevision(replicas[i]) == updateRevision.Name {
|
||||
}
|
||||
if getPodRevision(replicas[i]) == updateRevision.Name {
|
||||
status.UpdatedReplicas++
|
||||
}
|
||||
|
||||
@ -479,7 +482,8 @@ func (ssc *defaultStatefulSetControl) updateStatefulSet(
|
||||
}
|
||||
if getPodRevision(condemned[target]) == currentRevision.Name {
|
||||
status.CurrentReplicas--
|
||||
} else if getPodRevision(condemned[target]) == updateRevision.Name {
|
||||
}
|
||||
if getPodRevision(condemned[target]) == updateRevision.Name {
|
||||
status.UpdatedReplicas--
|
||||
}
|
||||
if monotonic {
|
||||
|
@ -128,6 +128,12 @@ func CreatesPods(t *testing.T, set *apps.StatefulSet, invariants invariantFunc)
|
||||
if set.Status.Replicas != 3 {
|
||||
t.Error("Failed to scale statefulset to 3 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 3 {
|
||||
t.Error("Failed to set ReadyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 3 {
|
||||
t.Error("Failed to set UpdatedReplicas correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func ScalesUp(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
@ -150,6 +156,12 @@ func ScalesUp(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
if set.Status.Replicas != 4 {
|
||||
t.Error("Failed to scale statefulset to 4 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 4 {
|
||||
t.Error("Failed to set readyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 4 {
|
||||
t.Error("Failed to set updatedReplicas correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func ScalesDown(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
@ -167,6 +179,12 @@ func ScalesDown(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
if set.Status.Replicas != 0 {
|
||||
t.Error("Failed to scale statefulset to 0 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 0 {
|
||||
t.Error("Failed to set readyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 0 {
|
||||
t.Error("Failed to set updatedReplicas correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func ReplacesPods(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
@ -298,6 +316,12 @@ func CreatePodFailure(t *testing.T, set *apps.StatefulSet, invariants invariantF
|
||||
if set.Status.Replicas != 3 {
|
||||
t.Error("Failed to scale StatefulSet to 3 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 3 {
|
||||
t.Error("Failed to set readyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 3 {
|
||||
t.Error("Failed to updatedReplicas correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func UpdatePodFailure(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
@ -318,6 +342,12 @@ func UpdatePodFailure(t *testing.T, set *apps.StatefulSet, invariants invariantF
|
||||
if set.Status.Replicas != 3 {
|
||||
t.Error("Failed to scale StatefulSet to 3 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 3 {
|
||||
t.Error("Failed to set readyReplicas correctly")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 3 {
|
||||
t.Error("Failed to set updatedReplicas correctly")
|
||||
}
|
||||
|
||||
// now mutate a pod's identity
|
||||
pods, err := spc.podsLister.List(labels.Everything())
|
||||
@ -357,6 +387,12 @@ func UpdateSetStatusFailure(t *testing.T, set *apps.StatefulSet, invariants inva
|
||||
if set.Status.Replicas != 3 {
|
||||
t.Error("Failed to scale StatefulSet to 3 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 3 {
|
||||
t.Error("Failed to set readyReplicas to 3")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 3 {
|
||||
t.Error("Failed to set updatedReplicas to 3")
|
||||
}
|
||||
}
|
||||
|
||||
func PodRecreateDeleteFailure(t *testing.T, set *apps.StatefulSet, invariants invariantFunc) {
|
||||
@ -436,6 +472,12 @@ func TestStatefulSetControlScaleDownDeleteError(t *testing.T) {
|
||||
if set.Status.Replicas != 0 {
|
||||
t.Error("Failed to scale statefulset to 0 replicas")
|
||||
}
|
||||
if set.Status.ReadyReplicas != 0 {
|
||||
t.Error("Failed to set readyReplicas to 0")
|
||||
}
|
||||
if set.Status.UpdatedReplicas != 0 {
|
||||
t.Error("Failed to set updatedReplicas to 0")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStatefulSetControl_getSetRevisions(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user