diff --git a/changelogs/fragments/102-wait-updated-daemonset-pods.yaml b/changelogs/fragments/102-wait-updated-daemonset-pods.yaml new file mode 100644 index 0000000000..2fc981de2f --- /dev/null +++ b/changelogs/fragments/102-wait-updated-daemonset-pods.yaml @@ -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). diff --git a/molecule/default/tasks/waiter.yml b/molecule/default/tasks/waiter.yml index 303cb2d1bb..44fc42b3ff 100644 --- a/molecule/default/tasks/waiter.yml +++ b/molecule/default/tasks/waiter.yml @@ -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 diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index 86b7ae9ac5..02d22c095d 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -403,6 +403,7 @@ def _pod_ready(pod): 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)