From 22a5a00c49b39e69eb601450a0b8f410b1d9cabb Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 12 Feb 2019 21:42:56 +0000 Subject: [PATCH] Improve kubeadm join tasks (#4206) Fix issue where `kubeadm join` could wait forever for joining. Fix issue where `kubeadm join` were not reaching the user, making impossible to find the cause of the failure. New behaviour is to first attempt to join without bypassing the verifications checks and to display them if needed. If this fails it still attempts to join by ignoring the check in order to make previous behavior. A timeout of 60 seconds is allocated for a joining. Related-bug: #3973 --- roles/kubernetes/kubeadm/tasks/main.yml | 36 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/roles/kubernetes/kubeadm/tasks/main.yml b/roles/kubernetes/kubeadm/tasks/main.yml index ba3991515..c849002b2 100644 --- a/roles/kubernetes/kubeadm/tasks/main.yml +++ b/roles/kubernetes/kubeadm/tasks/main.yml @@ -65,14 +65,38 @@ kubeadm_token: "{{ temp_token.stdout }}" - name: Join to cluster if needed - command: >- - {{ bin_dir }}/kubeadm join - --config {{ kube_config_dir}}/kubeadm-client.conf - --ignore-preflight-errors=all - register: kubeadm_join - when: not is_kube_master and (not kubelet_conf.stat.exists) environment: PATH: "{{ bin_dir }}:{{ ansible_env.PATH }}" + when: not is_kube_master and (not kubelet_conf.stat.exists) + block: + + - name: Join to cluster + command: >- + {{ bin_dir }}/kubeadm join + --config {{ kube_config_dir}}/kubeadm-client.conf + register: kubeadm_join + async: 60 + poll: 15 + + rescue: + + - name: Join to cluster with ignores + command: >- + {{ bin_dir }}/kubeadm join + --config {{ kube_config_dir}}/kubeadm-client.conf + --ignore-preflight-errors=all + register: kubeadm_join + async: 60 + poll: 15 + + always: + + - name: Display kubeadm join stderr if any + when: kubeadm_join is failed + debug: + message: | + Joined with warnings + {{ kubeadm_join.stderr_lines }} - name: Wait for kubelet bootstrap to create config wait_for: