mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #70401 from ravisantoshgudimetla/fix-e2e-node-capacity
Fix capacities as well
This commit is contained in:
commit
a525a2b4ee
@ -275,15 +275,19 @@ var _ = SIGDescribe("SchedulerPriorities [Serial]", func() {
|
|||||||
nodeName := lastNode.Name
|
nodeName := lastNode.Name
|
||||||
nodeOriginalMemory, found := lastNode.Status.Allocatable[v1.ResourceMemory]
|
nodeOriginalMemory, found := lastNode.Status.Allocatable[v1.ResourceMemory]
|
||||||
nodeOriginalCPU, found := lastNode.Status.Allocatable[v1.ResourceCPU]
|
nodeOriginalCPU, found := lastNode.Status.Allocatable[v1.ResourceCPU]
|
||||||
|
nodeOriginalCPUCapacity, found := lastNode.Status.Capacity[v1.ResourceCPU]
|
||||||
|
nodeOriginalMemoryCapacity, found := lastNode.Status.Capacity[v1.ResourceMemory]
|
||||||
Expect(found).To(Equal(true))
|
Expect(found).To(Equal(true))
|
||||||
nodeOriginalMemoryVal := nodeOriginalMemory.Value()
|
nodeOriginalMemoryVal := nodeOriginalMemory.Value()
|
||||||
nodeOriginalCPUVal := nodeOriginalCPU.MilliValue()
|
nodeOriginalCPUVal := nodeOriginalCPU.MilliValue()
|
||||||
err := updateNodeAllocatable(cs, nodeName, int64(10737418240), int64(12000))
|
nodeOriginalMemoryCapacityVal := nodeOriginalMemoryCapacity.Value()
|
||||||
|
nodeOriginalCPUCapacityVal := nodeOriginalCPUCapacity.MilliValue()
|
||||||
|
err := updateNodeResources(cs, nodeName, int64(10737418240), int64(12000), int64(10737418240), int64(12000))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
defer func() {
|
defer func() {
|
||||||
// Resize the node back to its original allocatable values.
|
// Resize the node back to its original allocatable values.
|
||||||
if err := updateNodeAllocatable(cs, nodeName, nodeOriginalMemoryVal, nodeOriginalCPUVal); err != nil {
|
if err := updateNodeResources(cs, nodeName, nodeOriginalMemoryVal, nodeOriginalCPUVal, nodeOriginalMemoryCapacityVal, nodeOriginalCPUCapacityVal); err != nil {
|
||||||
framework.Logf("Failed to revert node memory with %v", err)
|
framework.Logf("Failed to revert node resources with %v", err)
|
||||||
}
|
}
|
||||||
// Reset the node list with its old entry.
|
// Reset the node list with its old entry.
|
||||||
nodeList.Items[len(nodeList.Items)-1] = lastNode
|
nodeList.Items[len(nodeList.Items)-1] = lastNode
|
||||||
@ -458,15 +462,17 @@ func addRandomTaitToNode(cs clientset.Interface, nodeName string) *v1.Taint {
|
|||||||
return &testTaint
|
return &testTaint
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateNodeAllocatable updates the allocatable values of given node with the given values.
|
// updateNodeResources updates the resource of given node with the given values.
|
||||||
func updateNodeAllocatable(c clientset.Interface, nodeName string, memory, cpu int64) error {
|
func updateNodeResources(c clientset.Interface, nodeName string, memoryAllocatable, cpuAllocatable, memoryCapacity, cpuCapacity int64) error {
|
||||||
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
|
node, err := c.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
node.Status.Allocatable[v1.ResourceMemory] = *resource.NewQuantity(memory, resource.BinarySI)
|
node.Status.Capacity[v1.ResourceMemory] = *resource.NewQuantity(memoryCapacity, resource.BinarySI)
|
||||||
node.Status.Allocatable[v1.ResourceCPU] = *resource.NewMilliQuantity(cpu, resource.DecimalSI)
|
node.Status.Capacity[v1.ResourceCPU] = *resource.NewMilliQuantity(cpuCapacity, resource.DecimalSI)
|
||||||
|
node.Status.Allocatable[v1.ResourceMemory] = *resource.NewQuantity(memoryAllocatable, resource.BinarySI)
|
||||||
|
node.Status.Allocatable[v1.ResourceCPU] = *resource.NewMilliQuantity(cpuAllocatable, resource.DecimalSI)
|
||||||
_, err = c.CoreV1().Nodes().UpdateStatus(node)
|
_, err = c.CoreV1().Nodes().UpdateStatus(node)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user