Account for updated pods when waiting on DaemonSet (#102)

* Account for updated pods when waiting on DaemonSet

The exising logic that's used to determine when a DaemonSet is ready
fails to account for the fact that a RollingUpdate first kills the pod
and then creates a new one. Simply checking if the
desiredNumberScheduled equals the numberReady will succeed in cases
when the old pod takes time to shut down, and would report that the new
Deployment is ready despite the fact that the old pod has not been
replaced, yet.

* Add changelog fragment
This commit is contained in:
Mike Graves
2021-05-19 09:29:22 -04:00
committed by GitHub
parent 192cae1507
commit 0bbc9ca999
3 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
---
minor_changes:
- k8s - wait for all pods to update when rolling out daemonset changes (https://github.com/ansible-collections/kubernetes.core/pull/102).

View File

@@ -54,6 +54,9 @@
vars:
k8s_pod_name: wait-ds
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:1
k8s_pod_command:
- sleep
- "600"
register: ds
- name: Check that daemonset wait worked
@@ -82,6 +85,9 @@
vars:
k8s_pod_name: wait-ds
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:2
k8s_pod_command:
- sleep
- "600"
register: update_ds_check_mode
check_mode: yes
@@ -112,6 +118,9 @@
vars:
k8s_pod_name: wait-ds
k8s_pod_image: gcr.io/kuar-demo/kuard-amd64:3
k8s_pod_command:
- sleep
- "600"
register: ds
- name: Get updated pods

View File

@@ -403,6 +403,7 @@ class K8sAnsibleMixin(object):
def _daemonset_ready(daemonset):
return (daemonset.status and daemonset.status.desiredNumberScheduled is not None
and daemonset.status.updatedNumberScheduled == daemonset.status.desiredNumberScheduled
and daemonset.status.numberReady == daemonset.status.desiredNumberScheduled
and daemonset.status.observedGeneration == daemonset.metadata.generation
and not daemonset.status.unavailableReplicas)