Skip to content

fix(virt-handler): re-register device plugins after kubelet restart - #16

Open
rohan-togetherai wants to merge 2 commits into
release-1.4.0/togetherfrom
fix/device-plugin-reregister-clean
Open

fix(virt-handler): re-register device plugins after kubelet restart#16
rohan-togetherai wants to merge 2 commits into
release-1.4.0/togetherfrom
fix/device-plugin-reregister-clean

Conversation

@rohan-togetherai

Copy link
Copy Markdown

fix(virt-handler): re-register device plugins after kubelet restart

Problem

After kubelet restarts, PCI and generic device plugins can miss the restart signal and leave extended resources at allocatable 0. PCI restart cycles also reuse closed lifecycle channels, causing immediate deregistration and a duplicate-close panic.

Fix

Watch the device-plugin directory before registration and restart on plugin-socket removal, kubelet-socket creation, or directory removal/rename, including combined fsnotify masks. Reset PCI channels per cycle, join old gRPC handlers before the next cycle, and bound registration by shutdown and a five-second deadline.

Testing

Package tests run PCI and generic plugins through two real supervision cycles against a fake kubelet, cover restart filesystem events and watch ordering, and exercise handler joining and registration cancellation. The full package suite and five focused race-enabled runs pass.

Kubelet restarts exposed two independent failures. PCI and generic health checks only recognized an exact removal of their own socket, so a replaced device-plugin directory or a recreated kubelet socket could leave a plugin attached to a dead kubelet forever. PCI also reused lifecycle channels after teardown, causing its next ListAndWatch stream to deregister immediately and close an already-closed channel.

Install the socket-directory watch before Register and hand that watcher to the health loop. Restart on plugin-socket removal, kubelet-socket creation, or device-plugin directory removal or rename, and use fsnotify bit membership so combined operation masks retain their meaning. Derive the registration endpoint from the plugin socket directory, bound Register to the existing five-second connection window, and cancel it when the cycle stops.

Recreate PCI lifecycle channels for every Start. Close each cycle's done channel before stopping its server, and construct PCI and generic servers with WaitForHandlers so all old handlers are joined before the next cycle can replace their channels. This closes the cross-cycle race without changing the existing supervision and backoff model.

Co-authored-by: Aseef <contact@aseef.dev>
Co-authored-by: RITANKAR SAHA <ritankar.saha786@gmail.com>
Drive PCI and generic plugins through the real controlled-device loop against a fake kubelet and verify that both register again and continue advertising devices after a restart. Cover kubelet-socket recreation, device-plugin directory replacement, combined fsnotify masks, and rejection of unrelated events.

Exercise the watch-before-register ordering with an in-flight kubelet replacement, prove the production gRPC server waits for handlers while teardown wakes active ListAndWatch streams, and verify hung Register calls are cancelled on shutdown or fail at the deadline.
@broly-code-security-scanner

Copy link
Copy Markdown

Broly Security Scan

Note

Baseline snapshot is missing for this repo. Broly is running in PR-only fallback mode until the first scheduled baseline completes. This does not block the PR.

Note

Clean scan
No vulnerabilities detected in this PR.

Note

Re-scan this PR anytime with /broly scan — useful after /broly undismiss, or to refresh findings without a new push.

Broly — SAST (zai-org/GLM-5.3-Flash) · Secrets · SCA · IaC · GH Actions · Base Images · Supply Chain Threats · Exploit Chains · Adversarial Verification

We're continuously improving Broly's accuracy and finding quality — your feedback is valuable. False positives, missed findings, bugs, and feature requests all welcome.

Ask in #security-engineering   Powered by Together AI

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.

1 participant