Fix waiting on StatefulSet scale down (#391)

Fix waiting on StatefulSet scale down

SUMMARY

When scaling a StatefulSet down to 0 replicas the wait will fail
because some properties of the status (readyReplicas, updatedReplicas)
will not exist. These are probably defined as omitempty in the API and
since the value is zero are not present in the response.

Fixes #203
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_scale
ADDITIONAL INFORMATION

Reviewed-by: Gonéri Le Bouder <goneri@lebouder.net>
This commit is contained in:
Mike Graves
2022-03-11 12:32:12 -05:00
committed by GitHub
parent 30e84faa24
commit d68dec3b90
3 changed files with 56 additions and 2 deletions

View File

@@ -633,6 +633,10 @@ class K8sAnsibleMixin(object):
)
def _statefulset_ready(statefulset):
# These may be None
updated_replicas = statefulset.status.updatedReplicas or 0
ready_replicas = statefulset.status.readyReplicas or 0
return (
statefulset.status
and statefulset.spec.updateStrategy.type == "RollingUpdate"
@@ -640,8 +644,8 @@ class K8sAnsibleMixin(object):
== (statefulset.metadata.generation or 0)
and statefulset.status.updateRevision
== statefulset.status.currentRevision
and statefulset.status.updatedReplicas == statefulset.spec.replicas
and statefulset.status.readyReplicas == statefulset.spec.replicas
and updated_replicas == statefulset.spec.replicas
and ready_replicas == statefulset.spec.replicas
and statefulset.status.replicas == statefulset.spec.replicas
)