Skip removing nodes if cluster is not set (#9430)

This commit is contained in:
Ho Kim
2023-01-03 22:03:32 +09:00
committed by GitHub
parent 8ca0bfffe0
commit 4bc5e8d912
3 changed files with 12 additions and 4 deletions

View File

@@ -3,6 +3,8 @@
command: >-
{{ kubectl }} get nodes -o go-template={% raw %}'{{ range .items }}{{ .metadata.name }}{{ "\n" }}{{ end }}'{% endraw %}
register: nodes
when:
- groups['kube_control_plane'] | length > 0
delegate_to: "{{ groups['kube_control_plane']|first }}"
changed_when: false
run_once: true
@@ -15,8 +17,10 @@
--grace-period {{ drain_grace_period }}
--timeout {{ drain_timeout }}
--delete-emptydir-data {{ kube_override_hostname|default(inventory_hostname) }}
# ignore servers that are not nodes
when: kube_override_hostname|default(inventory_hostname) in nodes.stdout_lines
when:
- groups['kube_control_plane'] | length > 0
# ignore servers that are not nodes
- kube_override_hostname|default(inventory_hostname) in nodes.stdout_lines
register: result
failed_when: result.rc != 0 and not allow_ungraceful_removal
delegate_to: "{{ groups['kube_control_plane']|first }}"
@@ -34,5 +38,6 @@
retries: 3
delay: "{{ drain_grace_period }}"
when:
- groups['kube_control_plane'] | length > 0
- not allow_ungraceful_removal
- kube_override_hostname|default(inventory_hostname) in nodes.stdout_lines