Skip to content

Commit

Permalink
Controllers need to check using curl and http response code
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed Dec 4, 2024
1 parent 91c439a commit 6061e22
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions phase/install_controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,8 @@ func (p *InstallControllers) Run() error {
log.Infof("%s: validating api connection to %s using join token", h, h.Metadata.K0sTokenData.URL)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
err := retry.Context(ctx, func(_ context.Context) error {
out, err := h.ExecOutput(h.Configurer.KubectlCmdf(h, h.K0sDataDir(), "get --raw='/healthz' --kubeconfig=/dev/stdin"), exec.Sudo(h), exec.Stdin(string(h.Metadata.K0sTokenData.Kubeconfig)))
if out != "OK" {
log.Warnf("%s: k0s api /healthz response: %q", h, out)
}
if err != nil {
return fmt.Errorf("failed to connect from controller to kubernetes api - check networking: %w", err)
}
return nil
})
if err != nil {
return fmt.Errorf("connectivity check failed: %w", err)
if err := retry.Context(ctx, node.HTTPStatusFunc(h, h.Metadata.K0sTokenData.URL, 200, 401, 404)); err != nil {
return fmt.Errorf("failed to connect from controller to kubernetes api - check networking: %w", err)
}
} else {
log.Warnf("%s: dry-run: skipping api connection validation to because cluster is not actually running", h)
Expand Down

0 comments on commit 6061e22

Please sign in to comment.