From e0790d5a015dc03434bda0efe5a1435eab50f487 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Mon, 29 Jun 2026 10:21:48 +0300 Subject: [PATCH 1/2] e2e: test balloons publishing PCT HP CPUs as extended resources Signed-off-by: Antti Kervinen --- .../balloons/balloons-busybox.yaml.in | 6 ++++++ .../n4c16/test19-pct/balloons-pct-managed.cfg | 1 + .../balloons/n4c16/test19-pct/code.var.sh | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/test/e2e/policies.test-suite/balloons/balloons-busybox.yaml.in b/test/e2e/policies.test-suite/balloons/balloons-busybox.yaml.in index 359f4b6eb..2224b6548 100644 --- a/test/e2e/policies.test-suite/balloons/balloons-busybox.yaml.in +++ b/test/e2e/policies.test-suite/balloons/balloons-busybox.yaml.in @@ -30,12 +30,18 @@ spec: $(if [ -n "${MEMREQ}" ]; then echo " memory: '${MEMREQ}' "; fi) + $(for extreq in "${EXTREQ[@]}"; do echo " + $extreq + "; done) $(if [ -n "${CPULIM}" ]; then echo " limits: cpu: ${CPULIM} $(if [ -n "$MEMLIM" ]; then echo " memory: '${MEMLIM}' "; fi) + $(for extlim in "${EXTLIM[@]}"; do echo " + $extlim + "; done) "; fi) "; fi) "; done ) diff --git a/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/balloons-pct-managed.cfg b/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/balloons-pct-managed.cfg index 042449ea6..57271a2f8 100644 --- a/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/balloons-pct-managed.cfg +++ b/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/balloons-pct-managed.cfg @@ -39,6 +39,7 @@ config: minFreq: "turbo" maxFreq: "turbo" pctPriority: high + publishExtendedResource: true - name: pct-lp minFreq: "min" maxFreq: "base" diff --git a/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/code.var.sh b/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/code.var.sh index 6259d0d24..c3165d9da 100644 --- a/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/code.var.sh +++ b/test/e2e/policies.test-suite/balloons/n4c16/test19-pct/code.var.sh @@ -105,8 +105,15 @@ wait-assert-log-contains 'ConfigureClos.*ClosID:0 MinFreq:3800000 MaxFreq:380000 wait-assert-log-contains 'ConfigureClos.*ClosID:3 MinFreq:800000 MaxFreq:2900000' "LP CLOS 3 not programmed with MinFreq=min (800000) MaxFreq=base (2900000)" wait-assert-log-contains 'EnableCP done' "EnableCP missing" +vm-command "kubectl get nodes -o json | jq -r ' + .items[] | (.status.capacity[\"cpuclass.balloons.nri.io/pct-hp\"] // \"extended resource missing\")'" +[ "$COMMAND_OUTPUT" == "4" ] || \ + command-error "expected 4 PCT HP CPUs published as extended resources" + # Phase 1.2: schedule a pod in the HP balloon. CPUREQ=1 CPULIM=1 MEMREQ=10M MEMLIM=10M \ + EXTREQ="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ + EXTLIM="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ POD_ANNOTATION="balloon.balloons.resource-policy.nri.io: pct-hp-bln" CONTCOUNT=1 \ create balloons-busybox wait-assert-log-contains 'associated cpus .* to CLOS 0' "HP pod CPUs not associated to CLOS 0" @@ -138,6 +145,8 @@ verify 'cpus["pod1c0"].issubset({"cpu10","cpu11","cpu12","cpu13"})' # balloon should land on pkg1 because it has the larger HP room, # even though pkg0 also has free CPUs. CPUREQ=1 CPULIM=1 MEMREQ=10M MEMLIM=10M \ + EXTREQ="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ + EXTLIM="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ POD_ANNOTATION="balloon.balloons.resource-policy.nri.io: pct-hp2-bln" CONTCOUNT=1 \ create balloons-busybox report allowed @@ -159,6 +168,8 @@ verify 'packages["pod2c0"] != packages["pod0c0"]' pct-log 500 prev_to_clos0=$(grep -c 'to CLOS 0' <<< "$COMMAND_OUTPUT") CPUREQ=1 CPULIM=1 MEMREQ=10M MEMLIM=10M \ + EXTREQ="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ + EXTLIM="cpuclass.balloons.nri.io/pct-hp: \"1\"" \ POD_ANNOTATION="balloon.balloons.resource-policy.nri.io: pct-hp2-bln" CONTCOUNT=1 \ create balloons-busybox wait-assert-log-grew 'to CLOS 0' "$prev_to_clos0" "resize of pct-hp2-bln did not associate the new CPU(s) to CLOS 0" @@ -201,6 +212,11 @@ wait-assert-log-grew 'to CLOS 3' "$prev_to_clos3" "after deleting remaining pods helm-terminate +vm-command "kubectl get nodes -o json | jq -r ' + .items[] | (.status.capacity[\"cpuclass.balloons.nri.io/pct-hp\"] // \"extended resource missing\")'" +[ "$COMMAND_OUTPUT" == "extended resource missing" ] || \ + command-error "expected published extended resources to be cleaned up and missing after uninstall" + ############################################################################### # Phase 2: Assoc-only mode (sstClosID without pctPriority) ############################################################################### From 338ec9110881e16881905a6d23710bf216894776 Mon Sep 17 00:00:00 2001 From: Antti Kervinen Date: Mon, 29 Jun 2026 10:25:44 +0300 Subject: [PATCH 2/2] balloons: fix publishing PCT HP CPUs as extended resources Signed-off-by: Antti Kervinen --- cmd/plugins/balloons/policy/balloons-policy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/plugins/balloons/policy/balloons-policy.go b/cmd/plugins/balloons/policy/balloons-policy.go index 0f9a8ea54..b9176a153 100644 --- a/cmd/plugins/balloons/policy/balloons-policy.go +++ b/cmd/plugins/balloons/policy/balloons-policy.go @@ -607,7 +607,7 @@ func (p *balloons) GetExtendedResources() map[string]resource.Quantity { if free < 0 { free = 0 } - out["cpuclass.balloons.nri.io/"+cc.Name] = *resource.NewMilliQuantity(int64(free), resource.DecimalSI) + out["cpuclass.balloons.nri.io/"+cc.Name] = *resource.NewQuantity(int64(free), resource.DecimalSI) } return out }