Merge pull request #10387 from bhavin192/sts-ready-fix

fix(pkg/kube): statefulSetReady: handle partition cases correctly
pull/10201/head
Matthew Fisher 3 years ago committed by GitHub
commit ad71cc1ab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -377,7 +377,7 @@ func (c *ReadyChecker) statefulSetReady(sts *appsv1.StatefulSet) bool {
expectedReplicas := replicas - partition
// Make sure all the updated pods have been scheduled
if int(sts.Status.UpdatedReplicas) != expectedReplicas {
if int(sts.Status.UpdatedReplicas) < expectedReplicas {
c.log("StatefulSet is not ready: %s/%s. %d out of %d expected pods have been scheduled", sts.Namespace, sts.Name, sts.Status.UpdatedReplicas, expectedReplicas)
return false
}

@ -157,10 +157,24 @@ func Test_ReadyChecker_statefulSetReady(t *testing.T) {
{
name: "statefulset is not ready when partition is set",
args: args{
sts: newStatefulSet("foo", 1, 1, 1, 1),
sts: newStatefulSet("foo", 2, 1, 1, 0),
},
want: false,
},
{
name: "statefulset is ready when partition is set and no change in template",
args: args{
sts: newStatefulSet("foo", 2, 1, 2, 2),
},
want: true,
},
{
name: "statefulset is ready when partition is greater than replicas",
args: args{
sts: newStatefulSet("foo", 1, 2, 1, 1),
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

Loading…
Cancel
Save