mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
e2e node: wait for kubelet health check to pass after kubelet restart
Signed-off-by: Artyom Lukianov <alukiano@redhat.com>
This commit is contained in:
parent
a6b4868b8d
commit
ef3e0fd02f
@ -339,6 +339,14 @@ var _ = SIGDescribe("HugePages [Serial] [Feature:HugePages][NodeSpecialFeature:H
|
||||
ginkgo.By("restarting kubelet to pick up pre-allocated hugepages")
|
||||
// stop the kubelet and wait until the server will restart it automatically
|
||||
stopKubelet()
|
||||
// wait until the kubelet health check will fail
|
||||
gomega.Eventually(func() bool {
|
||||
return kubeletHealthCheck(kubeletHealthCheckURL)
|
||||
}, time.Minute, time.Second).Should(gomega.BeFalse())
|
||||
// wait until the kubelet health check will pass
|
||||
gomega.Eventually(func() bool {
|
||||
return kubeletHealthCheck(kubeletHealthCheckURL)
|
||||
}, 2*time.Minute, 10*time.Second).Should(gomega.BeTrue())
|
||||
|
||||
waitForHugepages()
|
||||
|
||||
|
@ -18,6 +18,7 @@ package e2enode
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
@ -70,6 +71,8 @@ const (
|
||||
defaultPodResourcesPath = "/var/lib/kubelet/pod-resources"
|
||||
defaultPodResourcesTimeout = 10 * time.Second
|
||||
defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb
|
||||
kubeletReadOnlyPort = "10255"
|
||||
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
|
||||
)
|
||||
|
||||
func getNodeSummary() (*stats.Summary, error) {
|
||||
@ -432,6 +435,27 @@ func stopKubelet() func() {
|
||||
}
|
||||
}
|
||||
|
||||
func kubeletHealthCheck(url string) bool {
|
||||
insecureTransport := http.DefaultTransport.(*http.Transport).Clone()
|
||||
insecureTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
insecureHTTPClient := &http.Client{
|
||||
Transport: insecureTransport,
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("HEAD", url, nil)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", framework.TestContext.BearerToken))
|
||||
resp, err := insecureHTTPClient.Do(req)
|
||||
if err != nil {
|
||||
klog.Warningf("Health check on %q failed, error=%v", url, err)
|
||||
} else if resp.StatusCode != http.StatusOK {
|
||||
klog.Warningf("Health check on %q failed, status=%d", url, resp.StatusCode)
|
||||
}
|
||||
return err == nil && resp.StatusCode == http.StatusOK
|
||||
}
|
||||
|
||||
func toCgroupFsName(cgroupName cm.CgroupName) string {
|
||||
if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" {
|
||||
return cgroupName.ToSystemd()
|
||||
|
Loading…
Reference in New Issue
Block a user