From c355cadbb1f5e9a40c5dd83d006a1c3efc346cba Mon Sep 17 00:00:00 2001 From: Itxaka Date: Tue, 3 Dec 2019 11:36:31 +0100 Subject: [PATCH] Enhance error message for failed controlplane init Currently if the controlplane fails to init, we print out a message with some example commands that only show docker CLI. This tries to improve that by printing the example commands for docker, cri-o and containerd by checking the socket looking for the default docker socket. --- .../app/cmd/phases/init/waitcontrolplane.go | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go b/cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go index ec6a4c04420..cd4fc31237c 100644 --- a/cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go +++ b/cmd/kubeadm/app/cmd/phases/init/waitcontrolplane.go @@ -47,11 +47,18 @@ var ( - 'journalctl -xeu kubelet' Additionally, a control plane component may have crashed or exited when started by the container runtime. - To troubleshoot, list all containers using your preferred container runtimes CLI, e.g. docker. + To troubleshoot, list all containers using your preferred container runtimes CLI. +{{ if .IsDocker }} Here is one example how you may list all Kubernetes containers running in docker: - 'docker ps -a | grep kube | grep -v pause' Once you have found the failing container, you can inspect its logs with: - 'docker logs CONTAINERID' +{{ else }} + Here is one example how you may list all Kubernetes containers running in cri-o/containerd using crictl: + - 'crictl --runtime-endpoint {{ .Socket }} ps -a | grep kube | grep -v pause' + Once you have found the failing container, you can inspect its logs with: + - 'crictl --runtime-endpoint {{ .Socket }} logs CONTAINERID' +{{ end }} `))) ) @@ -93,10 +100,17 @@ func runWaitControlPlanePhase(c workflow.RunData) error { fmt.Printf("[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory %q. This can take up to %v\n", data.ManifestDir(), timeout) if err := waiter.WaitForKubeletAndFunc(waiter.WaitForAPI); err != nil { - ctx := map[string]string{ - "Error": fmt.Sprintf("%v", err), + context := struct { + Error string + Socket string + IsDocker bool + }{ + Error: fmt.Sprintf("%v", err), + Socket: data.Cfg().NodeRegistration.CRISocket, + IsDocker: data.Cfg().NodeRegistration.CRISocket == kubeadmconstants.DefaultDockerCRISocket, } - kubeletFailTempl.Execute(data.OutputWriter(), ctx) + + kubeletFailTempl.Execute(data.OutputWriter(), context) return errors.New("couldn't initialize a Kubernetes cluster") }