Delete duplicate resource.Quantity.Copy()

This commit is contained in:
Tim Allclair
2019-08-19 17:23:14 -07:00
parent f4521bf5a2
commit 49f50484b8
20 changed files with 88 additions and 106 deletions

View File

@@ -88,7 +88,7 @@ func checkNodeAllocatableTest(f *framework.Framework) {
e2elog.Logf("nodeMem says: %+v", nodeMem)
// calculate the allocatable mem based on capacity - reserved amounts
calculatedNodeAlloc := nodeMem.capacity.Copy()
calculatedNodeAlloc := nodeMem.capacity.DeepCopy()
calculatedNodeAlloc.Sub(nodeMem.systemReserve)
calculatedNodeAlloc.Sub(nodeMem.kubeReserve)
calculatedNodeAlloc.Sub(nodeMem.softEviction)

View File

@@ -94,7 +94,7 @@ func getLocalNodeCPUDetails(f *framework.Framework) (cpuCapVal int64, cpuAllocVa
cpuCap := localNodeCap[v1.ResourceCPU]
localNodeAlloc := getLocalNode(f).Status.Allocatable
cpuAlloc := localNodeAlloc[v1.ResourceCPU]
cpuRes := cpuCap.Copy()
cpuRes := cpuCap.DeepCopy()
cpuRes.Sub(cpuAlloc)
// RoundUp reserved CPUs to get only integer cores.

View File

@@ -89,11 +89,13 @@ func getAllocatableLimits(cpu, memory, pids string, capacity v1.ResourceList) (*
// Total cpu reservation is 200m.
for k, v := range capacity {
if k == v1.ResourceCPU {
allocatableCPU = v.Copy()
c := v.DeepCopy()
allocatableCPU = &c
allocatableCPU.Sub(resource.MustParse(cpu))
}
if k == v1.ResourceMemory {
allocatableMemory = v.Copy()
c := v.DeepCopy()
allocatableMemory = &c
allocatableMemory.Sub(resource.MustParse(memory))
}
}