mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
skip reduceAllocatableMemoryUsage if cgroup v2 is enabled
This commit is contained in:
parent
522c1be4c1
commit
f0e7025371
@ -510,7 +510,7 @@ func runEvictionTest(f *framework.Framework, pressureTimeout time.Duration, expe
|
|||||||
ginkgo.Context("", func() {
|
ginkgo.Context("", func() {
|
||||||
ginkgo.BeforeEach(func() {
|
ginkgo.BeforeEach(func() {
|
||||||
// reduce memory usage in the allocatable cgroup to ensure we do not have MemoryPressure
|
// reduce memory usage in the allocatable cgroup to ensure we do not have MemoryPressure
|
||||||
reduceAllocatableMemoryUsage()
|
reduceAllocatableMemoryUsageIfCgroupv1()
|
||||||
// Nodes do not immediately report local storage capacity
|
// Nodes do not immediately report local storage capacity
|
||||||
// Sleep so that pods requesting local storage do not fail to schedule
|
// Sleep so that pods requesting local storage do not fail to schedule
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
@ -603,7 +603,7 @@ func runEvictionTest(f *framework.Framework, pressureTimeout time.Duration, expe
|
|||||||
return nil
|
return nil
|
||||||
}, pressureDisappearTimeout, evictionPollInterval).Should(gomega.BeNil())
|
}, pressureDisappearTimeout, evictionPollInterval).Should(gomega.BeNil())
|
||||||
|
|
||||||
reduceAllocatableMemoryUsage()
|
reduceAllocatableMemoryUsageIfCgroupv1()
|
||||||
ginkgo.By("making sure we have all the required images for testing")
|
ginkgo.By("making sure we have all the required images for testing")
|
||||||
prePullImagesIfNeccecary()
|
prePullImagesIfNeccecary()
|
||||||
|
|
||||||
|
@ -468,13 +468,16 @@ func toCgroupFsName(cgroupName cm.CgroupName) string {
|
|||||||
return cgroupName.ToCgroupfs()
|
return cgroupName.ToCgroupfs()
|
||||||
}
|
}
|
||||||
|
|
||||||
// reduceAllocatableMemoryUsage uses memory.force_empty (https://lwn.net/Articles/432224/)
|
// reduceAllocatableMemoryUsageIfCgroupv1 uses memory.force_empty (https://lwn.net/Articles/432224/)
|
||||||
// to make the kernel reclaim memory in the allocatable cgroup
|
// to make the kernel reclaim memory in the allocatable cgroup
|
||||||
// the time to reduce pressure may be unbounded, but usually finishes within a second
|
// the time to reduce pressure may be unbounded, but usually finishes within a second.
|
||||||
func reduceAllocatableMemoryUsage() {
|
// memory.force_empty is no supported in cgroupv2.
|
||||||
cmd := fmt.Sprintf("echo 0 > /sys/fs/cgroup/memory/%s/memory.force_empty", toCgroupFsName(cm.NewCgroupName(cm.RootCgroupName, defaultNodeAllocatableCgroup)))
|
func reduceAllocatableMemoryUsageIfCgroupv1() {
|
||||||
_, err := exec.Command("sudo", "sh", "-c", cmd).CombinedOutput()
|
if !IsCgroup2UnifiedMode() {
|
||||||
framework.ExpectNoError(err)
|
cmd := fmt.Sprintf("echo 0 > /sys/fs/cgroup/memory/%s/memory.force_empty", toCgroupFsName(cm.NewCgroupName(cm.RootCgroupName, defaultNodeAllocatableCgroup)))
|
||||||
|
_, err := exec.Command("sudo", "sh", "-c", cmd).CombinedOutput()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equivalent of featuregatetesting.SetFeatureGateDuringTest
|
// Equivalent of featuregatetesting.SetFeatureGateDuringTest
|
||||||
|
Loading…
Reference in New Issue
Block a user