From 34356fba11e6d62ed5d48f20a1f7cfab29b5ee75 Mon Sep 17 00:00:00 2001 From: Andrew Zagorodnuk Date: Tue, 10 May 2022 19:57:43 +0300 Subject: [PATCH] fix: Waiting until Volumes will be detached from the node on graceful node removal (#8739) --- roles/remove-node/pre-remove/tasks/main.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/roles/remove-node/pre-remove/tasks/main.yml b/roles/remove-node/pre-remove/tasks/main.yml index 32d4f9831aa..add5120dfe2 100644 --- a/roles/remove-node/pre-remove/tasks/main.yml +++ b/roles/remove-node/pre-remove/tasks/main.yml @@ -23,3 +23,16 @@ until: result.rc == 0 or allow_ungraceful_removal retries: "{{ drain_retries }}" delay: "{{ drain_retry_delay_seconds }}" + +- name: remove-node | Wait until Volumes will be detached from the node + command: >- + {{ kubectl }} get volumeattachments -o go-template={% raw %}'{{ range .items }}{{ .spec.nodeName }}{{ "\n" }}{{ end }}'{% endraw %} + register: nodes_with_volumes + delegate_to: "{{ groups['kube_control_plane']|first }}" + changed_when: false + until: not (kube_override_hostname|default(inventory_hostname) in nodes_with_volumes.stdout_lines) + retries: 3 + delay: "{{ drain_grace_period }}" + when: + - not allow_ungraceful_removal + - kube_override_hostname|default(inventory_hostname) in nodes.stdout_lines