Edited pre-upgrade task to uncordon a node failing to drain (#6546)

This commit is contained in:
Bernard Landon 2020-08-20 13:25:36 +02:00 committed by GitHub
parent d9d11e2291
commit fa378f09c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,10 +30,11 @@
false
{%- endif %}
- name: Node draining
block:
- name: Cordon node
command: "{{ bin_dir }}/kubectl cordon {{ kube_override_hostname|default(inventory_hostname) }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when: needs_cordoning
- name: Check kubectl version
command: "{{ bin_dir }}/kubectl version --client --short"
@ -43,7 +44,6 @@
changed_when: false
when:
- drain_nodes
- needs_cordoning
- drain_pod_selector
- name: Ensure minimum version for drain label selector if necessary
@ -51,7 +51,6 @@
that: "kubectl_version.stdout.split(' ')[-1] is version('v1.10.0', '>=')"
when:
- drain_nodes
- needs_cordoning
- drain_pod_selector
- name: Drain node
@ -63,7 +62,14 @@
--timeout {{ drain_timeout }}
--delete-local-data {{ kube_override_hostname|default(inventory_hostname) }}
{% if drain_pod_selector %}--pod-selector '{{ drain_pod_selector }}'{% endif %}
delegate_to: "{{ groups['kube-master'][0] }}"
when:
- drain_nodes
rescue:
- name: Set node back to schedulable
command: "{{ bin_dir }}/kubectl --kubeconfig /etc/kubernetes/admin.conf uncordon {{ inventory_hostname }}"
- name: Fail after rescue
fail:
msg: "Failed to drain node {{ inventory_hostname }}"
delegate_to: "{{ groups['kube-master'][0] }}"
when:
- needs_cordoning