From 7b1dc600d574591aca6af8b2932a73e36c804d86 Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Mon, 21 Mar 2022 01:39:10 -0700 Subject: [PATCH] Fix the condition of drain on pre-remove task (#8634) When running cluster.yml for new machines what containerd is already install but Kubernetes cluster were not installed before, the task "remove-node | List nodes" is failed like "changed": false, "cmd": [ "/usr/local/bin/kubectl", "--kubeconfig", "/etc/kubernetes/admin.conf", "get", "nodes", "-o", "go-template={{ range .items }}{{ .metadata.name }} {{ "\n" }}{{ end }}" ], .. "stderr": "error: stat /etc/kubernetes/admin.conf: no such file or directory", That was due to lack to check the existing Kubernetes cluster exists or not before running "kubectl drain" command. This adds the check to avoid the issue. --- .../validate-container-engine/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/roles/container-engine/validate-container-engine/tasks/main.yml b/roles/container-engine/validate-container-engine/tasks/main.yml index 0cd7d3623..22596e17c 100644 --- a/roles/container-engine/validate-container-engine/tasks/main.yml +++ b/roles/container-engine/validate-container-engine/tasks/main.yml @@ -63,6 +63,8 @@ apply: tags: - pre-remove + when: + - kubelet_systemd_unit_exists - name: Stop kubelet service: name: kubelet @@ -89,6 +91,8 @@ apply: tags: - pre-remove + when: + - kubelet_systemd_unit_exists - name: Stop kubelet service: name: kubelet @@ -114,6 +118,8 @@ apply: tags: - pre-remove + when: + - kubelet_systemd_unit_exists - name: Stop kubelet service: name: kubelet