Skip to content

Commit

Permalink
Account for updated pods when waiting on DaemonSet
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gravesm committed May 18, 2021
1 parent 5856948 commit 6d8894c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions molecule/default/tasks/waiter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6d8894c

Please sign in to comment.