default memoryThrottlingFactor to 0.9 and optimize the memory.high calculation formulas
This commit is contained in:
@@ -307,6 +307,8 @@ func TestGenerateContainerConfigWithMemoryQoSEnforced(t *testing.T) {
|
||||
_, _, m, err := createTestRuntimeManager()
|
||||
assert.NoError(t, err)
|
||||
|
||||
podRequestMemory := resource.MustParse("128Mi")
|
||||
pod1LimitMemory := resource.MustParse("256Mi")
|
||||
pod1 := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
UID: "12345678",
|
||||
@@ -323,10 +325,10 @@ func TestGenerateContainerConfigWithMemoryQoSEnforced(t *testing.T) {
|
||||
WorkingDir: "testWorkingDir",
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceMemory: resource.MustParse("128Mi"),
|
||||
v1.ResourceMemory: podRequestMemory,
|
||||
},
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceMemory: resource.MustParse("256Mi"),
|
||||
v1.ResourceMemory: pod1LimitMemory,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -350,7 +352,7 @@ func TestGenerateContainerConfigWithMemoryQoSEnforced(t *testing.T) {
|
||||
WorkingDir: "testWorkingDir",
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceMemory: resource.MustParse("128Mi"),
|
||||
v1.ResourceMemory: podRequestMemory,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -358,7 +360,8 @@ func TestGenerateContainerConfigWithMemoryQoSEnforced(t *testing.T) {
|
||||
},
|
||||
}
|
||||
memoryNodeAllocatable := resource.MustParse(fakeNodeAllocatableMemory)
|
||||
pod2MemoryHigh := float64(memoryNodeAllocatable.Value()) * m.memoryThrottlingFactor
|
||||
pod1MemoryHigh := float64(podRequestMemory.Value()) + (float64(pod1LimitMemory.Value())-float64(podRequestMemory.Value()))*m.memoryThrottlingFactor
|
||||
pod2MemoryHigh := float64(podRequestMemory.Value()) + (float64(memoryNodeAllocatable.Value())-float64(podRequestMemory.Value()))*m.memoryThrottlingFactor
|
||||
|
||||
type expectedResult struct {
|
||||
containerConfig *runtimeapi.LinuxContainerConfig
|
||||
@@ -378,7 +381,7 @@ func TestGenerateContainerConfigWithMemoryQoSEnforced(t *testing.T) {
|
||||
expected: &expectedResult{
|
||||
l1,
|
||||
128 * 1024 * 1024,
|
||||
int64(float64(256*1024*1024) * m.memoryThrottlingFactor),
|
||||
int64(pod1MemoryHigh),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user