@@ -19,10 +19,8 @@ package phases
19
19
import (
20
20
"fmt"
21
21
"io"
22
- "text/template"
23
22
"time"
24
23
25
- "github.com/lithammer/dedent"
26
24
"github.com/pkg/errors"
27
25
28
26
v1 "k8s.io/api/core/v1"
@@ -38,28 +36,6 @@ import (
38
36
staticpodutil "k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod"
39
37
)
40
38
41
- var (
42
- kubeletFailTempl = template .Must (template .New ("init" ).Parse (dedent .Dedent (`
43
- Unfortunately, an error has occurred:
44
- {{ .Error }}
45
-
46
- This error is likely caused by:
47
- - The kubelet is not running
48
- - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
49
-
50
- If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
51
- - 'systemctl status kubelet'
52
- - 'journalctl -xeu kubelet'
53
-
54
- Additionally, a control plane component may have crashed or exited when started by the container runtime.
55
- To troubleshoot, list all containers using your preferred container runtimes CLI.
56
- Here is one example how you may list all running Kubernetes containers by using crictl:
57
- - 'crictl --runtime-endpoint {{ .Socket }} ps -a | grep kube | grep -v pause'
58
- Once you have found the failing container, you can inspect its logs with:
59
- - 'crictl --runtime-endpoint {{ .Socket }} logs CONTAINERID'
60
- ` )))
61
- )
62
-
63
39
// NewWaitControlPlanePhase is a hidden phase that runs after the control-plane and etcd phases
64
40
func NewWaitControlPlanePhase () workflow.Phase {
65
41
phase := workflow.Phase {
@@ -102,27 +78,15 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
102
78
" from directory %q\n " ,
103
79
data .ManifestDir ())
104
80
105
- handleError := func (err error ) error {
106
- context := struct {
107
- Error string
108
- Socket string
109
- }{
110
- Error : fmt .Sprintf ("%v" , err ),
111
- Socket : data .Cfg ().NodeRegistration .CRISocket ,
112
- }
113
-
114
- kubeletFailTempl .Execute (data .OutputWriter (), context )
115
- return errors .New ("could not initialize a Kubernetes cluster" )
116
- }
117
-
118
81
waiter .SetTimeout (data .Cfg ().Timeouts .KubeletHealthCheck .Duration )
119
82
kubeletConfig := data .Cfg ().ClusterConfiguration .ComponentConfigs [componentconfigs .KubeletGroup ].Get ()
120
83
kubeletConfigTyped , ok := kubeletConfig .(* kubeletconfig.KubeletConfiguration )
121
84
if ! ok {
122
85
return errors .New ("could not convert the KubeletConfiguration to a typed object" )
123
86
}
124
87
if err := waiter .WaitForKubelet (kubeletConfigTyped .HealthzBindAddress , * kubeletConfigTyped .HealthzPort ); err != nil {
125
- return handleError (err )
88
+ apiclient .PrintKubeletErrorHelpScreen (data .OutputWriter ())
89
+ return errors .Wrap (err , "failed while waiting for the kubelet to start" )
126
90
}
127
91
128
92
var podMap map [string ]* v1.Pod
@@ -138,7 +102,8 @@ func runWaitControlPlanePhase(c workflow.RunData) error {
138
102
err = waiter .WaitForAPI ()
139
103
}
140
104
if err != nil {
141
- return handleError (err )
105
+ apiclient .PrintControlPlaneErrorHelpScreen (data .OutputWriter (), data .Cfg ().NodeRegistration .CRISocket )
106
+ return errors .Wrap (err , "failed while waiting for the control plane to start" )
142
107
}
143
108
144
109
return nil
0 commit comments