Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to probes, Kubelet initialized #951

Merged
merged 3 commits into from
Jul 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions pkg/tasks/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const (

kubeletVersionDPKG = `dpkg-query --show --showformat='${Version}' kubelet | cut -d- -f1`
kubeletVersionRPM = `rpm -qa --queryformat '%{RPMTAG_VERSION}' kubelet`
kubeletVersionCLI = `kubelet --version | cut -d' ' -f2`

kubeletInitializedCMD = `test -f /etc/kubernetes/kubelet.conf`
)

func runProbes(s *state.State) error {
Expand Down Expand Up @@ -83,6 +86,10 @@ func investigateHost(s *state.State, node *kubeoneapi.HostConfig, conn ssh.Conne
return err
}

if err := detectKubeletInitialized(h, conn); err != nil {
return err
}

fmt.Println("---------------")
fmt.Printf("host: %q\n", h.Hostname)
fmt.Printf("docker version: %q\n", h.ContainerRuntime.Version)
Expand All @@ -97,6 +104,7 @@ func investigateHost(s *state.State, node *kubeoneapi.HostConfig, conn ssh.Conne
fmt.Printf("kubelet is running?: %t\n", h.Kubernetes.Status&state.SystemDStatusRunning != 0)
fmt.Printf("kubelet is active?: %t\n", h.Kubernetes.Status&state.SystemDStatusActive != 0)
fmt.Printf("kubelet is restarting?: %t\n", h.Kubernetes.Status&state.SystemDStatusRestarting != 0)
fmt.Printf("kubelet is initialized?: %t\n", h.Kubernetes.Status&state.KubeletInitialized != 0)
fmt.Println()

s.LiveCluster.Lock.Lock()
Expand Down Expand Up @@ -166,9 +174,7 @@ func detectKubeletStatusVersion(host *state.Host, conn ssh.Connection) error {
case kubeoneapi.OperatingSystemNameUbuntu:
kubeletVersionCmd = kubeletVersionDPKG
case kubeoneapi.OperatingSystemNameFlatcar, kubeoneapi.OperatingSystemNameCoreOS:
// TODO: FIXME:
host.Kubernetes.Version = &semver.Version{}
return nil
kubeletVersionCmd = kubeletVersionCLI
default:
return nil
}
Expand All @@ -187,6 +193,21 @@ func detectKubeletStatusVersion(host *state.Host, conn ssh.Connection) error {
return nil
}

func detectKubeletInitialized(host *state.Host, conn ssh.Connection) error {
_, _, exitcode, err := conn.Exec(kubeletInitializedCMD)
if err != nil && exitcode <= 0 {
// If there's an error and exit code is 0, there's mostly like a connection
// error. If exit code is -1, there might be a session problem.
return err
}

if exitcode == 0 {
host.Kubernetes.Status |= state.KubeletInitialized
}

return nil
}

func systemdStatus(conn ssh.Connection, service string) (uint64, error) {
out, _, _, err := conn.Exec(fmt.Sprintf(systemdShowStatusCMD, service))
if err != nil {
Expand Down