Skip to content

Commit 10bf2a2

Browse files
committed
UPSTREAM: <carry>: adapt to the old API
update code and tests to work with older codebase. This PR can be dropped when we rebase. Signed-off-by: Francesco Romani <[email protected]>
1 parent c52de76 commit 10bf2a2

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

pkg/kubelet/cm/cpumanager/cpu_assignment.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func (a *cpuAccumulator) takeFullSockets() {
390390
func (a *cpuAccumulator) takeFullUncore() {
391391
for _, uncore := range a.freeUncoreCache() {
392392
cpusInUncore := a.topo.CPUDetails.CPUsInUncoreCaches(uncore)
393-
if !a.needsAtLeast(cpusInUncore.Size()) {
393+
if !a.needs(cpusInUncore.Size()) {
394394
continue
395395
}
396396
klog.V(4).InfoS("takeFullUncore: claiming uncore", "uncore", uncore)
@@ -427,7 +427,7 @@ func (a *cpuAccumulator) takeUncoreCache() {
427427
numCPUsInUncore := a.topo.CPUsPerUncore()
428428
for _, uncore := range a.sortAvailableUncoreCaches() {
429429
// take full UncoreCache if the CPUs needed is greater than free UncoreCache size
430-
if a.needsAtLeast(numCPUsInUncore) {
430+
if a.needs(numCPUsInUncore) {
431431
a.takeFullUncore()
432432
}
433433

pkg/kubelet/cm/cpumanager/cpu_assignment_test.go

+28-2
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,33 @@ func TestTakeByTopologyNUMAPacked(t *testing.T) {
651651
"",
652652
mustParseCPUSet(t, "0-29,40-69,30,31,70,71"),
653653
},
654-
// Test cases for PreferAlignByUncoreCache
654+
}...)
655+
656+
for _, tc := range testCases {
657+
t.Run(tc.description, func(t *testing.T) {
658+
result, err := takeByTopologyNUMAPacked(tc.topo, tc.availableCPUs, tc.numCPUs, false)
659+
if tc.expErr != "" && err != nil && err.Error() != tc.expErr {
660+
t.Errorf("expected error to be [%v] but it was [%v]", tc.expErr, err)
661+
}
662+
if !result.Equals(tc.expResult) {
663+
t.Errorf("expected result [%s] to equal [%s]", result, tc.expResult)
664+
}
665+
})
666+
}
667+
}
668+
669+
type takeByTopologyUncoreTestCase struct {
670+
description string
671+
topo *topology.CPUTopology
672+
opts StaticPolicyOptions
673+
availableCPUs cpuset.CPUSet
674+
numCPUs int
675+
expErr string
676+
expResult cpuset.CPUSet
677+
}
678+
679+
func TestTakeByTopologyUncore(t *testing.T) {
680+
testCases := []takeByTopologyUncoreTestCase{
655681
{
656682
"take cpus from two full UncoreCaches and partial from a single UncoreCache",
657683
topoUncoreSingleSocketNoSMT,
@@ -724,7 +750,7 @@ func TestTakeByTopologyNUMAPacked(t *testing.T) {
724750
"",
725751
mustParseCPUSet(t, "4-7,12-15,1,9"),
726752
},
727-
}...)
753+
}
728754

729755
for _, tc := range testCases {
730756
t.Run(tc.description, func(t *testing.T) {

0 commit comments

Comments
 (0)