k8s_scale - handle scaling StatefulSets with 'updateStrategy=OnDelete' (#579)

k8s_scale - handle scaling StatefulSets with 'updateStrategy=OnDelete'

SUMMARY

Likely Fixes #503

Handle scaling StatefulSets with 'updateStrategy=OnDelete'
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

k8s_scale
ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: Bikouo Aubin <None>
This commit is contained in:
Mandar Kulkarni
2023-02-06 12:04:41 -08:00
committed by GitHub
parent 0f7963beb9
commit deaf8ee4f3
3 changed files with 75 additions and 0 deletions

View File

@@ -61,6 +61,13 @@ def daemonset_ready(daemonset: ResourceInstance) -> bool:
def statefulset_ready(statefulset: ResourceInstance) -> bool:
if statefulset.spec.updateStrategy.type == "OnDelete":
return bool(
statefulset.status
and statefulset.status.observedGeneration
== (statefulset.metadata.generation or 0)
and statefulset.status.replicas == statefulset.spec.replicas
)
# These may be None
updated_replicas = statefulset.status.updatedReplicas or 0
ready_replicas = statefulset.status.readyReplicas or 0