Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged

Conversation

mandar242
Copy link
Contributor

SUMMARY

Likely Fixes #503

Handle scaling StatefulSets with 'updateStrategy=OnDelete'

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

k8s_scale

ADDITIONAL INFORMATION

@softwarefactory-project-zuul
Copy link

Build succeeded.

✔️ build-ansible-collection SUCCESS in 4m 16s
ansible-test-sanity-docker-devel FAILURE in 13m 24s (non-voting)
ansible-test-sanity-docker-milestone FAILURE in 12m 56s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.9 SUCCESS in 15m 42s
✔️ ansible-test-sanity-docker-stable-2.11 SUCCESS in 16m 22s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 12m 20s
✔️ ansible-test-units-kubernetes-core-python38 SUCCESS in 11m 19s
✔️ ansible-test-splitter SUCCESS in 3m 23s
✔️ integration-kubernetes.core-devel-1 SUCCESS in 14m 38s (non-voting)
✔️ integration-kubernetes.core-devel-2 SUCCESS in 11m 13s (non-voting)
⚠️ integration-kubernetes.core-devel-3 SKIPPED (non-voting)
✔️ integration-kubernetes.core-milestone-1 SUCCESS in 13m 53s
✔️ integration-kubernetes.core-milestone-2 SUCCESS in 8m 20s
⚠️ integration-kubernetes.core-milestone-3 SKIPPED
✔️ integration-kubernetes.core-2.9-1 SUCCESS in 11m 20s
✔️ integration-kubernetes.core-2.9-2 SUCCESS in 11m 41s
⚠️ integration-kubernetes.core-2.9-3 SKIPPED
✔️ integration-kubernetes.core-2.10-1 SUCCESS in 12m 50s
✔️ integration-kubernetes.core-2.10-2 SUCCESS in 12m 57s
⚠️ integration-kubernetes.core-2.10-3 SKIPPED
✔️ integration-kubernetes.core-with-turbo-1 SUCCESS in 15m 55s
✔️ integration-kubernetes.core-with-turbo-2 SUCCESS in 11m 17s
⚠️ integration-kubernetes.core-with-turbo-3 SKIPPED
✔️ ansible-tox-linters SUCCESS in 8m 10s
✔️ ansible-test-changelog SUCCESS in 3m 22s
✔️ ansible-galaxy-importer SUCCESS in 8m 34s

@@ -66,7 +66,7 @@ def statefulset_ready(statefulset: ResourceInstance) -> bool:
ready_replicas = statefulset.status.readyReplicas or 0
return bool(
statefulset.status
and statefulset.spec.updateStrategy.type == "RollingUpdate"
and statefulset.spec.updateStrategy.type in ["RollingUpdate", "OnDelete"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a bit tricky. The problem with StatefulSets that use OnDelete is that the currentRevision and updateRevision may not match, since pods aren't replaced until they are manually deleted. In some cases, updatedReplicas may also not match the spec's replicas. You can see this by creating a StatefulSet using the OnDelete update strategy and more than one replica. Then, in a separate task, modify the container spec. Now, scale it down to 1 replica.

I think what we need here is two sets of conditions, one for RollingUpdate and one for OnDelete. The block for OnDelete should not check the revision or the updated replicas. So something like:

if statefulset.spec.updateStrategy.type == "OnDelete":
    return bool(...) # modified condition checks
return bool(...) # current condition checks

@softwarefactory-project-zuul
Copy link

Build succeeded.

✔️ build-ansible-collection SUCCESS in 3m 14s
ansible-test-sanity-docker-devel FAILURE in 7m 42s (non-voting)
ansible-test-sanity-docker-milestone FAILURE in 7m 32s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.9 SUCCESS in 9m 33s
✔️ ansible-test-sanity-docker-stable-2.11 SUCCESS in 9m 24s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 9m 02s
✔️ ansible-test-units-kubernetes-core-python38 SUCCESS in 5m 36s
✔️ ansible-test-splitter SUCCESS in 2m 24s
✔️ integration-kubernetes.core-devel-1 SUCCESS in 11m 48s (non-voting)
✔️ integration-kubernetes.core-devel-2 SUCCESS in 7m 25s (non-voting)
⚠️ integration-kubernetes.core-devel-3 SKIPPED (non-voting)
✔️ integration-kubernetes.core-milestone-1 SUCCESS in 10m 28s
✔️ integration-kubernetes.core-milestone-2 SUCCESS in 6m 10s
⚠️ integration-kubernetes.core-milestone-3 SKIPPED
✔️ integration-kubernetes.core-2.9-1 SUCCESS in 10m 48s
✔️ integration-kubernetes.core-2.9-2 SUCCESS in 6m 19s
⚠️ integration-kubernetes.core-2.9-3 SKIPPED
✔️ integration-kubernetes.core-2.10-1 SUCCESS in 10m 36s
✔️ integration-kubernetes.core-2.10-2 SUCCESS in 7m 05s
⚠️ integration-kubernetes.core-2.10-3 SKIPPED
✔️ integration-kubernetes.core-with-turbo-1 SUCCESS in 10m 28s
✔️ integration-kubernetes.core-with-turbo-2 SUCCESS in 6m 07s
⚠️ integration-kubernetes.core-with-turbo-3 SKIPPED
✔️ ansible-tox-linters SUCCESS in 4m 44s
✔️ ansible-test-changelog SUCCESS in 2m 10s
✔️ ansible-galaxy-importer SUCCESS in 3m 56s

@softwarefactory-project-zuul
Copy link

Build succeeded (gate pipeline).

✔️ build-ansible-collection SUCCESS in 3m 15s
ansible-test-sanity-docker-devel FAILURE in 9m 00s (non-voting)
ansible-test-sanity-docker-milestone FAILURE in 9m 37s (non-voting)
✔️ ansible-test-sanity-docker-stable-2.9 SUCCESS in 10m 47s
✔️ ansible-test-sanity-docker-stable-2.11 SUCCESS in 10m 18s
✔️ ansible-test-sanity-docker-stable-2.12 SUCCESS in 8m 45s
✔️ ansible-test-units-kubernetes-core-python38 SUCCESS in 6m 01s
✔️ ansible-test-splitter SUCCESS in 2m 28s
✔️ integration-kubernetes.core-devel-1 SUCCESS in 12m 27s (non-voting)
✔️ integration-kubernetes.core-devel-2 SUCCESS in 7m 16s (non-voting)
⚠️ integration-kubernetes.core-devel-3 SKIPPED (non-voting)
✔️ integration-kubernetes.core-milestone-1 SUCCESS in 11m 36s
✔️ integration-kubernetes.core-milestone-2 SUCCESS in 7m 23s
⚠️ integration-kubernetes.core-milestone-3 SKIPPED
✔️ integration-kubernetes.core-2.9-1 SUCCESS in 12m 03s
✔️ integration-kubernetes.core-2.9-2 SUCCESS in 7m 58s
⚠️ integration-kubernetes.core-2.9-3 SKIPPED
✔️ integration-kubernetes.core-2.10-1 SUCCESS in 10m 48s
✔️ integration-kubernetes.core-2.10-2 SUCCESS in 6m 43s
⚠️ integration-kubernetes.core-2.10-3 SKIPPED
✔️ integration-kubernetes.core-with-turbo-1 SUCCESS in 11m 29s
✔️ integration-kubernetes.core-with-turbo-2 SUCCESS in 13m 01s
⚠️ integration-kubernetes.core-with-turbo-3 SKIPPED
✔️ ansible-tox-linters SUCCESS in 5m 00s
✔️ ansible-test-changelog SUCCESS in 2m 14s
✔️ ansible-galaxy-importer SUCCESS in 3m 48s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit deaf8ee into ansible-collections:main Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubernetes.core.k8s_scale doesn't scale statefulsets
3 participants