mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +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")
|
ginkgo.By("restarting kubelet to pick up pre-allocated hugepages")
|
||||||
// stop the kubelet and wait until the server will restart it automatically
|
// stop the kubelet and wait until the server will restart it automatically
|
||||||
stopKubelet()
|
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()
|
waitForHugepages()
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package e2enode
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -70,6 +71,8 @@ const (
|
|||||||
defaultPodResourcesPath = "/var/lib/kubelet/pod-resources"
|
defaultPodResourcesPath = "/var/lib/kubelet/pod-resources"
|
||||||
defaultPodResourcesTimeout = 10 * time.Second
|
defaultPodResourcesTimeout = 10 * time.Second
|
||||||
defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb
|
defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb
|
||||||
|
kubeletReadOnlyPort = "10255"
|
||||||
|
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getNodeSummary() (*stats.Summary, error) {
|
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 {
|
func toCgroupFsName(cgroupName cm.CgroupName) string {
|
||||||
if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" {
|
if framework.TestContext.KubeletConfig.CgroupDriver == "systemd" {
|
||||||
return cgroupName.ToSystemd()
|
return cgroupName.ToSystemd()
|
||||||
|
Loading…
Reference in New Issue
Block a user