Skip to content

Commit

Permalink
Remove system pods running check (#802)
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
  • Loading branch information
kke authored Dec 3, 2024
1 parent 0aa7b09 commit 388ec1e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 73 deletions.
8 changes: 0 additions & 8 deletions phase/reinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,5 @@ func (p *Reinstall) reinstall(h *cluster.Host) error {
return nil
}

log.Infof("%s: waiting for system pods to become ready", h)
if err := retry.Timeout(context.TODO(), retry.DefaultTimeout, node.SystemPodsRunningFunc(h)); err != nil {
if !Force {
return fmt.Errorf("all system pods not running after api start-up, you can ignore this check by using --force: %w", err)
}
log.Warnf("%s: failed to observe system pods running after api start-up: %s", h, err)
}

return nil
}
8 changes: 0 additions & 8 deletions phase/upgrade_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,5 @@ func (p *UpgradeControllers) Run() error {
log.Warnf("%s: failed to observe scheduling events after api start-up: %s", leader, err)
}

log.Infof("%s: waiting for system pods to become ready", leader)
if err := retry.Timeout(context.TODO(), retry.DefaultTimeout, node.SystemPodsRunningFunc(leader)); err != nil {
if !Force {
return fmt.Errorf("all system pods not running after api start-up, you can ignore this check by using --force: %w", err)
}
log.Warnf("%s: failed to observe system pods running after api start-up: %s", leader, err)
}

return nil
}
57 changes: 0 additions & 57 deletions pkg/node/statusfunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ type statusEvents struct {
} `json:"items"`
}

// kubectl get pods -o json
type podStatusList struct {
Items []struct {
Status struct {
ContainerStatuses []struct {
ContainerID string `json:"containerID"`
Name string `json:"name"`
Ready bool `json:"ready"`
} `json:"containerStatuses"`
Phase string `json:"phase"`
} `json:"status"`
} `json:"items"`
}

// KubeNodeReady returns a function that returns an error unless the node is ready according to "kubectl get node"
func KubeNodeReadyFunc(h *cluster.Host) retryFunc {
return func(_ context.Context) error {
Expand Down Expand Up @@ -125,49 +111,6 @@ func ScheduledEventsAfterFunc(h *cluster.Host, since time.Time) retryFunc {
}
}

// SystemPodsRunningFunc returns a function that returns an error unless all kube-system pods are running
func SystemPodsRunningFunc(h *cluster.Host) retryFunc {
return func(_ context.Context) error {
output, err := h.ExecOutput(h.Configurer.KubectlCmdf(h, h.K0sDataDir(), "-n kube-system get pods -o json"), exec.HideOutput(), exec.Sudo(h))
if err != nil {
return fmt.Errorf("failed to get kube-system pods: %w", err)
}
pods := &podStatusList{}
if err := json.Unmarshal([]byte(output), &pods); err != nil {
return fmt.Errorf("failed to decode kubectl output for get kube-system pods: %w", err)
}

var running int
var notReady int

for _, p := range pods.Items {
if p.Status.Phase != "Running" {
log.Tracef("%s: pod phase '%s' - container statuses: %+v", h, p.Status.Phase, p.Status.ContainerStatuses)
continue
}
running++
for _, c := range p.Status.ContainerStatuses {
if !c.Ready {
log.Debugf("%s: container %s not ready", h, c.Name)
notReady++
}
}
}

if running == 0 {
return fmt.Errorf("no kube-system pods running")
}

if notReady > 0 {
return fmt.Errorf("%d kube-system containers not ready", notReady)
}

log.Debugf("%s: all (%d) system pods running", h, running)

return nil
}
}

// HTTPStatus returns a function that returns an error unless the expected status code is returned for a HTTP get to the url
func HTTPStatusFunc(h *cluster.Host, url string, expected ...int) retryFunc {
return func(_ context.Context) error {
Expand Down

0 comments on commit 388ec1e

Please # to comment.