orchestrator: add inspect-nbd CLI tool and DevicePool.Status() - #3547
Open
AdaAibaby wants to merge 4 commits into
Open
orchestrator: add inspect-nbd CLI tool and DevicePool.Status()#3547AdaAibaby wants to merge 4 commits into
AdaAibaby wants to merge 4 commits into
Conversation
Fixes e2b-dev#3546. The nbd kernel module is loaded with nbds_max=4096, pre-creating 4096 /dev/nbdX block devices on every sandbox node. `lsblk | grep nbd` produces 4096 lines of noise even when zero sandboxes are running, making it impossible to quickly identify which devices are actively connected. ConnectedDevices() in pool.go already scans /sys/block/nbdX/pid to find connected slots, but was not exposed via any operator-facing tool. Changes: - Add cmd/inspect-nbd: reads ConnectedDevices() and prints a table of active NBD slots with device path, size, and PID. Supports -json for machine-readable output. Linux-only (//go:build linux). - Add DevicePool.maxDevices field: stored at construction to avoid re-reading /sys/module/nbd/parameters/nbds_max on each call. - Add DevicePool.Status() -> PoolStatus: returns Max/Used/PreWarmed counts from the in-memory bitset without scanning sysfs — usable by future debug endpoints. Example output on a node with 4096 configured but only 1 connected: NBD devices: 1 connected / 4096 configured SLOT DEVICE SIZE (MB) PID 1 /dev/nbd1 22691 3321246
AdaAibaby
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
August 7, 2026 07:34
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5ec3453053
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3546.
Summary
cmd/inspect-nbd: new operator tool that shows only the NBD devices currently connected on the host, instead of all 4096 pre-allocated onesDevicePool.maxDevices: stored at construction to avoid re-reading/sys/module/nbd/parameters/nbds_maxon each callDevicePool.Status(): returnsPoolStatus{Max, Used, PreWarmed}from the in-memory bitset without scanning sysfs — for future debug endpointsMotivation
The
nbdmodule is loaded withnbds_max=4096(start-client.sh), pre-creating 4096/dev/nbdXblock devices.lsblk | grep nbdproduces 4096 lines of noise even with zero sandboxes running. When kernel errors likeblock nbd316: Receive control failedappear indmesg, there is no way to identify which sandbox is involved.ConnectedDevices()already had the right logic (scans/sys/block/nbdX/pid), but was only used internally for startup reclaim. This PR exposes it as a standalone tool.Usage
Verified on dev sandbox node (
192.168.162.80,nbds_max=4096, 1 sandbox running at test time).Not in scope
Slot → sandbox ID mapping (requires threading sandboxID through
GetDevicecall sites) — tracked in #3546 as follow-up.