@@ -42,20 +42,6 @@ type statusEvents struct {
4242 } `json:"items"`
4343}
4444
45- // kubectl get pods -o json
46- type podStatusList struct {
47- Items []struct {
48- Status struct {
49- ContainerStatuses []struct {
50- ContainerID string `json:"containerID"`
51- Name string `json:"name"`
52- Ready bool `json:"ready"`
53- } `json:"containerStatuses"`
54- Phase string `json:"phase"`
55- } `json:"status"`
56- } `json:"items"`
57- }
58-
5945// KubeNodeReady returns a function that returns an error unless the node is ready according to "kubectl get node"
6046func KubeNodeReadyFunc (h * cluster.Host ) retryFunc {
6147 return func (_ context.Context ) error {
@@ -125,49 +111,6 @@ func ScheduledEventsAfterFunc(h *cluster.Host, since time.Time) retryFunc {
125111 }
126112}
127113
128- // SystemPodsRunningFunc returns a function that returns an error unless all kube-system pods are running
129- func SystemPodsRunningFunc (h * cluster.Host ) retryFunc {
130- return func (_ context.Context ) error {
131- output , err := h .ExecOutput (h .Configurer .KubectlCmdf (h , h .K0sDataDir (), "-n kube-system get pods -o json" ), exec .HideOutput (), exec .Sudo (h ))
132- if err != nil {
133- return fmt .Errorf ("failed to get kube-system pods: %w" , err )
134- }
135- pods := & podStatusList {}
136- if err := json .Unmarshal ([]byte (output ), & pods ); err != nil {
137- return fmt .Errorf ("failed to decode kubectl output for get kube-system pods: %w" , err )
138- }
139-
140- var running int
141- var notReady int
142-
143- for _ , p := range pods .Items {
144- if p .Status .Phase != "Running" {
145- log .Tracef ("%s: pod phase '%s' - container statuses: %+v" , h , p .Status .Phase , p .Status .ContainerStatuses )
146- continue
147- }
148- running ++
149- for _ , c := range p .Status .ContainerStatuses {
150- if ! c .Ready {
151- log .Debugf ("%s: container %s not ready" , h , c .Name )
152- notReady ++
153- }
154- }
155- }
156-
157- if running == 0 {
158- return fmt .Errorf ("no kube-system pods running" )
159- }
160-
161- if notReady > 0 {
162- return fmt .Errorf ("%d kube-system containers not ready" , notReady )
163- }
164-
165- log .Debugf ("%s: all (%d) system pods running" , h , running )
166-
167- return nil
168- }
169- }
170-
171114// HTTPStatus returns a function that returns an error unless the expected status code is returned for a HTTP get to the url
172115func HTTPStatusFunc (h * cluster.Host , url string , expected ... int ) retryFunc {
173116 return func (_ context.Context ) error {
0 commit comments