fix: ectd集群有不正常节点时删除etcd节点失败

pull/749/head
gjmzj 2019-11-26 03:06:12 +00:00
parent d28628d87f
commit d0c7938a48
3 changed files with 13 additions and 3 deletions

View File

@ -34,20 +34,26 @@
- debug: var="ETCD_CLUSTER_STATUS.stdout"
- debug: var="ETCD_CLUSTER_STATUS.stderr"
- name: get a running ectd node
shell: 'echo -e "{{ ETCD_CLUSTER_STATUS.stdout }}"|grep "is healthy"|sed -n "1p"|cut -d: -f2|cut -d/ -f3'
shell: 'echo -e "{{ ETCD_CLUSTER_STATUS.stdout }}" \
"{{ ETCD_CLUSTER_STATUS.stderr }}" \
|grep "is healthy"|sed -n "1p"|cut -d: -f2|cut -d/ -f3'
register: RUNNING_NODE
- debug: var="RUNNING_NODE.stdout"
# step2: remove jobs run on the healthy member if needed
- name: get ID of etcd node to delete
shell: "ETCDCTL_API=3 {{ bin_dir }}/etcdctl member list|grep {{ ETCD_TO_DEL }}:2380|cut -d',' -f1"
shell: "ETCDCTL_API=3 {{ bin_dir }}/etcdctl member list \
|grep {{ ETCD_TO_DEL }}:2380|cut -d',' -f1"
register: ETCD_ID
delegate_to: "{{ RUNNING_NODE.stdout }}"
- name: get NAME of etcd node to delete
shell: "ETCDCTL_API=3 {{ bin_dir }}/etcdctl member list|grep {{ ETCD_TO_DEL }}:2380|cut -d' ' -f3|cut -d',' -f1"
shell: "ETCDCTL_API=3 {{ bin_dir }}/etcdctl member list \
|grep {{ ETCD_TO_DEL }}:2380|cut -d' ' -f3|cut -d',' -f1"
register: ETCD_NAME
delegate_to: "{{ RUNNING_NODE.stdout }}"

View File

@ -20,6 +20,8 @@
- debug: var="CLEAN_STATUS.stdout"
- debug: var="CLEAN_STATUS.stderr"
- name: run kubectl delete node {{ NODE_TO_DEL }}
shell: "{{ bin_dir }}/kubectl delete node {{ NODE_TO_DEL }}"
ignore_errors: true

View File

@ -21,6 +21,8 @@
- debug: var="CLEAN_STATUS.stdout"
- debug: var="CLEAN_STATUS.stderr"
- name: run kubectl delete node {{ NODE_TO_DEL }}
shell: "{{ bin_dir }}/kubectl delete node {{ NODE_TO_DEL }}"
ignore_errors: true