[bug]: Node lock leak when getAllocateResponse fails in NvidiaDevicePlugin.Allocate
What happened:
In pkg/device-plugin/nvidiadevice/nvinternal/plugin/server.go, inside NvidiaDevicePlugin.Allocate(), if plugin.getAllocateResponse() returns an error in the non-MIG allocation path (lines 648โ651), the function returns the error immediately without calling PodAllocationFailed(nodename, current, NodeLockNvidia).
Because PodAllocationFailed() is skipped, the node lock (hami.io/mutex.lock) is not released, causing subsequent GPU allocation requests on that node to hang or fail.
What you expected to happen:
When plugin.getAllocateResponse() fails, PodAllocationFailed(nodename, current, NodeLockNvidia) should be invoked to release the node lock before returning the error, consistent with all other error handling paths inside Allocate().
How to reproduce it (as minimally and precisely as possible):
- Inspect
pkg/device-plugin/nvidiadevice/nvinternal/plugin/server.golines 648โ651 - Trigger a failure in getAllocateResponse() (for example, via an invalid CDI specification or configuration).
- Observe that the node lock hami.io/mutex.lock is not released upon error return.
Environment:
- HAMi version: master (https://github.com/Project-HAMi/HAMi/commit/05e6c800b41c5544356682ad5b6bf19d8d6fe838)
Project-HAMi/HAMi#1989 - Export nvidia device plugin methods for ascend device plugin [merged]
Project-HAMi/HAMi#2011 - feat: new mutex GPU scheduling policy [merged]
Project-HAMi/HAMi#2043 - fix(device-plugin): avoid nil pointer panic in CheckHealth when checkHealth returns nil [merged]
Project-HAMi/HAMi#2054 - fix: skip owner check for legacy lock format [merged]
Project-HAMi/HAMi#2087 - feat(device-plugin): support CDI-only NVIDIA accelerators (GB10) [open]๐ Related PRs
๐ Issue Planner
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
- [ ] Create Plan
๐งช Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
๐ฌ Have feedback or questions? Drop into our discord!
@archlitchi, i would love to get your thoughts on this, if confirmed, i can raise a pr to fix it
@cotishq I don't know whether Kubelet will retry calling Allocate after an error returned. If so, we can't simply release the lock because it will break the assumption that only one Pod is being creating duration the Allocate function.
@Shouren i dug into the lock implementation more carefully, actually ReleaseNodeLock in pkg/util/nodelock/nodelock.go already has a pod-ownership verification, that checks the annotation owner matches the current pod before releasing, so a retry with different pod would be a safe no-op. on whether kubelet retries - it doesnt in current k8s, Allocate() errors cause immedieate UnexpectedAdmissionError. The actual impact of this missing call is like the lock sits on the node annotation until the TTL expires, blocking all GPU allocations, and all other paths already calls it so this one is the only inconsistent abt it, if this aligns well with you, i would happy to open a pr with the one-line fix .
@cotishq Since there is no retry mechanism for Pods with UnexpectedAdmissionError, I think it is safe to release the NodeLock.