mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Merge pull request #31566 from ronnielai/container-gc
Automatic merge from submit-queue Avoid disk eviction node e2e test using up all the disk space
This commit is contained in:
commit
d3270bce71
@ -110,6 +110,12 @@ var _ = framework.KubeDescribe("Kubelet Eviction Manager [Serial] [Disruptive]",
|
|||||||
nodeDiskPressureCondition := false
|
nodeDiskPressureCondition := false
|
||||||
podRescheduleable := false
|
podRescheduleable := false
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
|
// Avoid the test using up all the disk space
|
||||||
|
err := checkDiskUsage(0.05)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// The pod should be evicted.
|
// The pod should be evicted.
|
||||||
if !evictionOccurred {
|
if !evictionOccurred {
|
||||||
podData, err := podClient.Get(busyPodName)
|
podData, err := podClient.Get(busyPodName)
|
||||||
@ -227,3 +233,29 @@ func isImageSupported() bool {
|
|||||||
// instead of skipping images the eviction thresholds should be adjusted based on the images.
|
// instead of skipping images the eviction thresholds should be adjusted based on the images.
|
||||||
return strings.Contains(framework.TestContext.NodeName, "-gci-dev-")
|
return strings.Contains(framework.TestContext.NodeName, "-gci-dev-")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// checkDiskUsage verifies that the available bytes on disk are above the limit.
|
||||||
|
func checkDiskUsage(limit float64) error {
|
||||||
|
summary, err := getNodeSummary()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if nodeFs := summary.Node.Fs; nodeFs != nil {
|
||||||
|
if nodeFs.AvailableBytes != nil && nodeFs.CapacityBytes != nil {
|
||||||
|
if float64(*nodeFs.CapacityBytes)*limit > float64(*nodeFs.AvailableBytes) {
|
||||||
|
return fmt.Errorf("available nodefs byte is less than %v%%", limit*float64(100))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if summary.Node.Runtime != nil {
|
||||||
|
if imageFs := summary.Node.Runtime.ImageFs; imageFs != nil {
|
||||||
|
if float64(*imageFs.CapacityBytes)*limit > float64(*imageFs.AvailableBytes) {
|
||||||
|
return fmt.Errorf("available imagefs byte is less than %v%%", limit*float64(100))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user