agent v0.23.0: expose per-drive capacity (total/used/fraction) in GET /disks for the controller capacity bar

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-11 21:30:38 +02:00
parent 15f7529a1c
commit 832b73e6e8
+9 -2
View File
@@ -77,6 +77,10 @@ type DiskInfo struct {
Role string `json:"role"` Role string `json:"role"`
DataBearing bool `json:"data_bearing"` // agent device-inspection verdict (UI hint) DataBearing bool `json:"data_bearing"` // agent device-inspection verdict (UI hint)
DataReason string `json:"data_reason,omitempty"` DataReason string `json:"data_reason,omitempty"`
// Capacity (from the agent's storage view) — for the controller's capacity bar. 0 when unknown.
TotalBytes int64 `json:"total_bytes"`
UsedBytes int64 `json:"used_bytes"`
UsedFraction float64 `json:"used_fraction"`
// DurableID is the target's stable identity (e.g. "uuid:<fs-uuid>" for usb/local-dir). The // DurableID is the target's stable identity (e.g. "uuid:<fs-uuid>" for usb/local-dir). The
// controller strips the "uuid:" prefix to get the fs UUID it passes to POST /disks/assign — // controller strips the "uuid:" prefix to get the fs UUID it passes to POST /disks/assign —
// the only way the (de-privileged) controller can learn the mount key it cannot read itself. // the only way the (de-privileged) controller can learn the mount key it cannot read itself.
@@ -102,8 +106,11 @@ func (s *Server) handleDisks(w http.ResponseWriter, r *http.Request, vmid int) {
di := DiskInfo{ di := DiskInfo{
Name: t.Name, Type: t.Type, State: t.State, Name: t.Name, Type: t.Type, State: t.State,
BackingDevice: t.BackingDevice, MountPath: t.MountPath, Class: t.ClassHint, BackingDevice: t.BackingDevice, MountPath: t.MountPath, Class: t.ClassHint,
DurableID: t.DurableID, DurableID: t.DurableID,
Role: string(storage.RoleForStorage(t.Type, t.BackingDevice, sysDisks, sysKnown)), Role: string(storage.RoleForStorage(t.Type, t.BackingDevice, sysDisks, sysKnown)),
TotalBytes: t.TotalBytes,
UsedBytes: t.UsedBytes,
UsedFraction: t.UsedFraction,
} }
// Inspect the backing device for the UI's data-bearing hint (the authoritative check // Inspect the backing device for the UI's data-bearing hint (the authoritative check
// is re-run at format time on the actual device). // is re-run at format time on the actual device).