Skip to content

DRA: refresh node resources after claim changes - #829

Merged
klihub merged 2 commits into
mainfrom
stacked/bart0sh/DRA/008-resmgr-refresh-node-resources
Oct 16, 2026
Merged

klihub merged 2 commits into
mainfrom
stacked/bart0sh/DRA/008-resmgr-refresh-node-resources

Conversation

@bart0sh

@bart0sh bart0sh commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Refreshing node resources after claim changes

Eighth PR of the DRA series, on top of #823. Two commits: resmgr refreshes
the node resources after a claim change, and the test42-dra-devices e2e test
checks the NodeResourceTopology CR after a claim and after its release.

The NRI path refreshes the NodeResourceTopology CR and the node's extended
resources after every change to the policy's allocations. The claim path did
not, so after a claim was allocated or released both kept what the last NRI
event left them. With topology-aware, the CR then still showed the claimed CPUs
as free.

Now ClaimAllocated and ClaimReleased refresh both, after saving the cache
and updating the containers. A failed refresh is logged, as on the NRI path,
and does not fail the claim: it does not change what the claim was given. A
failed allocation is rolled back through ClaimReleased, which refreshes then.

A small helper, updateNodeResources(), now does the refresh. It replaces the
paired updateTopologyZones()/updateNodeExtendedResources() calls on the NRI
path and after a reconfiguration, so there is one list of what gets refreshed.

No policy or interface change is needed: the policy still answers
GetTopologyZones and GetExtendedResources when resmgr asks.

The e2e test

test42-dra-devices reads the shared cpuset attribute of a NUMA node's zone
in the CR. After a claim takes CPUs of a node, the zone must stop listing them.
After the claim is released, it must list them again. The NRI path also
refreshes the CR when the claiming container is created, so the first check is
only a sanity check. No container event follows the release, so the second
check passes only if the claim path refreshes the CR. The test's cpuset()
helper now also accepts an empty string, which is what a zone with no shared
CPUs left reports.

What is not here

These are known limitations, each lifted by a later PR in the series:

  • Claims do not survive a restart. They are saved with the other grants,
    but the policy resets its saved state on start, so after the plugin
    restarts their CPUs are free again and can be granted twice.
  • No DeviceClass ships yet, so a claim needs one written by the user.

Verification

  • go test -race ./... passes, and golangci-lint finds no issues in
    pkg/resmgr.
  • TestClaimCommitRefreshesNodeResources checks that allocating and releasing
    a claim each refresh the node resources once, and that a failing NRT CR
    update does not fail either call. Removing either of the two new calls fails
    the test.
  • test42-dra-devices passes on n4c16 with Kubernetes 1.37, containerd
    v2.4.1, and the DRAConsumableCapacity and DRANodeAllocatableResources
    gates. A claim for 2 CPUs of node 0 got 0-1, the CR dropped 0-1 from the
    zone's shared CPUs, and listed them again after the claim was released.

@bart0sh
bart0sh added this pull request to stack #807 October 8, 2026 14:23
@bart0sh bart0sh changed the title resmgr: refresh node resources after DRA claim changes. DRA: refresh node resources after claim changes Oct 8, 2026
@bart0sh
bart0sh requested a balanced review from Copilot October 9, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Asynchronous NRT refreshes can execute out of order and restore stale pre-release data.

1 open finding
What changed in this PR

Refreshes exported node resources after DRA claim allocation and release.

Changes:

  • Centralizes node-resource refreshes.
  • Refreshes NRT and extended resources after claim changes.
  • Adds unit and end-to-end coverage.
File Description
pkg/​resmgr/​resource-manager.go Adds the shared refresh helper.
pkg/​resmgr/​nri.go Uses the helper for NRI events.
pkg/​resmgr/​dra.go Refreshes resources after claim changes.
pkg/​resmgr/​dra_test.go Tests claim-triggered refreshes.
pkg/​resmgr/​nri_test.go Adds the required test agent.
test/​e2e/​.../​code.var.sh Verifies NRT claim updates.
test/​e2e/​.../​py_consts.var.py Supports empty CPU sets.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/resmgr/dra.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The confirmed asynchronous NRT refresh ordering race remains unresolved and can leave the post-release topology stale.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@bart0sh
bart0sh marked this pull request as ready for review October 12, 2026 07:49
@askervin
askervin force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch from caf8313 to e139127 Compare October 12, 2026 14:53
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch 2 times, most recently from ea5356f to 538ce5d Compare October 13, 2026 12:54
@bart0sh
bart0sh requested review from askervin and klihub October 15, 2026 10:42
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch from 538ce5d to d28110d Compare October 15, 2026 11:35
Base automatically changed from stacked/bart0sh/DRA/007-topology-aware-pin-claimed-cpus to main October 15, 2026 11:41
@klihub
klihub force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch from d28110d to 030a2ab Compare October 15, 2026 11:41
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch 2 times, most recently from dbe04d6 to d28110d Compare October 15, 2026 12:14
A claim changes what the policy has free, which the NRT CR and the
node's extended resources report. Refresh both after a claim is
allocated or released, as the NRI path does after container changes.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
@bart0sh
bart0sh force-pushed the stacked/bart0sh/DRA/008-resmgr-refresh-node-resources branch from d28110d to 95791b8 Compare October 15, 2026 12:55
#

cleanup() {
vm-command "kubectl delete pods --all --now --wait" || :

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we have now common test helpers in lib/test.bash, including a delete-pods which we could use here. I think most (maybe all) of the other test cases have already been converted to use it. There are a bunch of others and this DRA test probably slipped through, because it was not in the merged main tree when we converted the others. Not even nearly a show-stopper to get this merged, but maybe you could push another PR on the stack to convert it to be closer to the rest.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bart0sh Actually, let's forget about doing this change here. You also have pending #834 touching the same tests, and we did a sweep and there is quite a bunch of the other existing test cases which also could use a 2nd unification round. So my suggestion would be to get in this and #834, and then we'll merge a larger test case unification and cleanup PR, to take care of a larger bunch.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bart0sh Here is a draft with a larger sweep to take care of most of the tests. #855. We can consider taking it in once #829 #831 and #834 are in.

@klihub klihub left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to me good to go in now.

The potential NRT ordering problem is true and real but it has nothing to do with the changes here. It's been there forever, because we never really fixed the problem in the original implementation (synchronous update slowing down policy decisions), instead we just half-arsed hid it by tossing in an async goroutine and calling it a day. We can and should fix that separately from this.

@askervin askervin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@klihub
klihub merged commit 78faab7 into main Oct 16, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants