e2b-dev / e2b-dev/runtime

orchestrator: no CLI to inspect active NBD devices; lsblk shows 4096 pre-allocated noise

Open
#3,546 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
1.6k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Problem

On a sandbox node, running lsblk | grep nbd | wc -l returns 4096 — one line per pre-allocated device. All show SIZE=0B when idle, making it impossible to quickly identify which devices are actively connected to a sandbox.

# current operator experience
$ lsblk | grep nbd | wc -l
4096

# no easy way to filter to just connected ones

The 4096 devices are expected — start-client.sh loads the nbd module with nbds_max=4096 and this is persisted in /etc/modprobe.d/nbd.conf. This is correct behavior. The problem is observability: there is no tool to see which of those 4096 slots are actually in use.

What exists today

pkg/sandbox/nbd/pool.go already has the machinery:

  • ConnectedDevices() — scans /sys/block/nbdX/pid and returns only connected slots
  • DevicePool.usedSlots — a bitset of pool-tracked slots (not accessible externally)
  • OTEL metrics: orchestrator.nbd.slots_pool.acquired/released/ready — aggregate counts only

None of this is exposed via a CLI or debug endpoint. When a kernel I/O error like block nbd316: Receive control failed appears in dmesg, there is no way to correlate nbd316 to a sandbox ID.

Missing pieces

  1. No CLI tool that calls ConnectedDevices() and prints a table of active devices (slot, path, size, PID) — analogous to cmd/inspect-build
  2. No slot → sandbox ID mapping in DevicePool — even internally, usedSlots only tracks which slots are occupied, not which sandbox occupies each slot
  3. DevicePool doesn't store maxDevices — callers must re-read /sys/module/nbd/parameters/nbds_max to know the pool ceiling

Proposed fix

Add cmd/inspect-nbd: a lightweight operator tool that shows only active NBD devices.

Example output:

NBD devices: 3 connected / 4096 configured

SLOT   DEVICE      SIZE (MB)  PID
3      /dev/nbd3   1024       18234
17     /dev/nbd17  2048       18891
316    /dev/nbd316 1024       19012

Flags: -json for machine-readable output.

Secondary improvement: store maxDevices on DevicePool at construction (avoids re-reading sysfs on every call) and expose a Status() method returning used/max counts for future debug endpoints.

Slot → sandbox ID mapping is left as follow-up work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pkg/sandbox/nbd/pool.go, especially ConnectedDevices and DevicePool construction, then compare the entry point and conventions in cmd/inspect-build. Done means cmd/inspect-nbd reports connected slots with device, size, and PID, supports -json, and includes the proposed pool status and configured maximum handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
cli, observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.