mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
fix last minute scheduler changes for inplace update
This commit is contained in:
parent
7db339dba2
commit
fd6105d015
@ -1542,20 +1542,22 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
pod := testpod.DeepCopy()
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
pod.Spec.Containers[0].Resources.Requests = tt.requests
|
pod := testpod.DeepCopy()
|
||||||
pod.Status.ContainerStatuses[0].ResourcesAllocated = tt.resourcesAllocated
|
pod.Spec.Containers[0].Resources.Requests = tt.requests
|
||||||
pod.Status.Resize = tt.resizeStatus
|
pod.Status.ContainerStatuses[0].ResourcesAllocated = tt.resourcesAllocated
|
||||||
|
pod.Status.Resize = tt.resizeStatus
|
||||||
|
|
||||||
res, non0CPU, non0Mem := calculateResource(pod)
|
res, non0CPU, non0Mem := calculateResource(pod)
|
||||||
if !reflect.DeepEqual(tt.expectedResource, res) {
|
if !reflect.DeepEqual(tt.expectedResource, res) {
|
||||||
t.Errorf("Test: %s expected resource: %+v, got: %+v", tt.name, tt.expectedResource, res)
|
t.Errorf("Test: %s expected resource: %+v, got: %+v", tt.name, tt.expectedResource, res)
|
||||||
}
|
}
|
||||||
if non0CPU != tt.expectedNon0CPU {
|
if non0CPU != tt.expectedNon0CPU {
|
||||||
t.Errorf("Test: %s expected non0CPU: %d, got: %d", tt.name, tt.expectedNon0CPU, non0CPU)
|
t.Errorf("Test: %s expected non0CPU: %d, got: %d", tt.name, tt.expectedNon0CPU, non0CPU)
|
||||||
}
|
}
|
||||||
if non0Mem != tt.expectedNon0Mem {
|
if non0Mem != tt.expectedNon0Mem {
|
||||||
t.Errorf("Test: %s expected non0Mem: %d, got: %d", tt.name, tt.expectedNon0Mem, non0Mem)
|
t.Errorf("Test: %s expected non0Mem: %d, got: %d", tt.name, tt.expectedNon0Mem, non0Mem)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1487,8 +1487,12 @@ func doPodResizeSchedulerTests() {
|
|||||||
nodeAllocatableMilliCPU := n.Status.Allocatable.Cpu().MilliValue()
|
nodeAllocatableMilliCPU := n.Status.Allocatable.Cpu().MilliValue()
|
||||||
gomega.Expect(n.Status.Allocatable != nil)
|
gomega.Expect(n.Status.Allocatable != nil)
|
||||||
podAllocatedMilliCPU := int64(0)
|
podAllocatedMilliCPU := int64(0)
|
||||||
listOptions := metav1.ListOptions{FieldSelector: "spec.nodeName=" + n.Name}
|
|
||||||
|
// Exclude pods that are in the Succeeded or Failed states
|
||||||
|
selector := fmt.Sprintf("spec.nodeName=%s,status.phase!=%v,status.phase!=%v", n.Name, v1.PodSucceeded, v1.PodFailed)
|
||||||
|
listOptions := metav1.ListOptions{FieldSelector: selector}
|
||||||
podList, err := f.ClientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), listOptions)
|
podList, err := f.ClientSet.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), listOptions)
|
||||||
|
|
||||||
framework.ExpectNoError(err, "failed to get running pods")
|
framework.ExpectNoError(err, "failed to get running pods")
|
||||||
framework.Logf("Found %d pods on node '%s'", len(podList.Items), n.Name)
|
framework.Logf("Found %d pods on node '%s'", len(podList.Items), n.Name)
|
||||||
for _, pod := range podList.Items {
|
for _, pod := range podList.Items {
|
||||||
@ -1560,7 +1564,7 @@ func doPodResizeSchedulerTests() {
|
|||||||
framework.ExpectEqual(testPod2.Status.Phase, v1.PodPending)
|
framework.ExpectEqual(testPod2.Status.Phase, v1.PodPending)
|
||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("TEST1: Resize pod '%s' to fit in node '%s'", testPod2.Name, node.Name))
|
ginkgo.By(fmt.Sprintf("TEST1: Resize pod '%s' to fit in node '%s'", testPod2.Name, node.Name))
|
||||||
testPod2, pErr := f.ClientSet.CoreV1().Pods(testPod2.Namespace).Patch(context.TODO(),
|
testPod2, pErr := f.ClientSet.CoreV1().Pods(testPod2.Namespace).Patch(ctx,
|
||||||
testPod2.Name, types.StrategicMergePatchType, []byte(patchTestpod2ToFitNode), metav1.PatchOptions{})
|
testPod2.Name, types.StrategicMergePatchType, []byte(patchTestpod2ToFitNode), metav1.PatchOptions{})
|
||||||
framework.ExpectNoError(pErr, "failed to patch pod for resize")
|
framework.ExpectNoError(pErr, "failed to patch pod for resize")
|
||||||
|
|
||||||
@ -1629,7 +1633,7 @@ func doPodResizeSchedulerTests() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ = SIGDescribe("[Serial] Pod InPlace Resize Container (scheduler-focussed) [Feature:InPlacePodVerticalScaling]", func() {
|
var _ = SIGDescribe("[Serial] Pod InPlace Resize Container (scheduler-focused) [Feature:InPlacePodVerticalScaling]", func() {
|
||||||
doPodResizeSchedulerTests()
|
doPodResizeSchedulerTests()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user