Skip to content

Add sled slot to disks in externals /hardware/disks endpoint - #11221

Open
fakemonster wants to merge 4 commits into
mainfrom
jt/disk-slot
Open

Add sled slot to disks in externals /hardware/disks endpoint#11221
fakemonster wants to merge 4 commits into
mainfrom
jt/disk-slot

Conversation

@fakemonster

Copy link
Copy Markdown

Kind of like #11077, but for disks! Particularly it's similar in that it's grafting the slot number on from an inventory check. The hope in the linked issue is that it'd be unnecessary in this case because physical_disk gets recreated when disks are moved between sleds, so we could potentially add a slot column to phsyical_disk and skip the inventory check. But as far as I can tell, a disk readopted to the same sled won't go through the same flow, so we'd need bigger changes to accomplish that.

Additionally, this refactors the inventory's disk Vec into an IdOrdMap for a bit of convenience. This is done as its own commit to be easily revertable, in case it's undesirable, but I believe it's a generally reasonable improvement, and the side effects justified (discussed in that commit's message body).

Resolves #11088

fakemonster and others added 4 commits September 1, 2026 20:29
Using an IdOrdMap means less scanning for disk slots on calls to the
/system/disks API, but it has a few side effects, all of which I believe
are benign:

1. While the DiskIdentity strikes me as a reasonable key, it doesn't
   match the primary key `inv_physical_disk` uses, and so a DB lookup
   could in principle report the same DiskIdentity for two slots, and
   we'll drop one of the duplicates now. This deduplication also applies
   at collection time, meaning if prior to this commit we were recording
   two disks with the same identity into crdb, that'll no longer happen
   (which may then hide an unhealthy case we'd want to catch!). But I
   don't believe this is a problem in principle, because the
   `physical_disk` table itself has a unique index on the components of
   DiskIdentity, so a duplicate disk would be unadoptable anyways.
2. Relatedly, since that case seems unlikely, I opted for `from_iter`
   instead of `from_iter_unique`. It would perhaps be more rigorous to
   attempt `from_iter_unique`, and loudly fall back to `from_iter`?
3. When omdb lists disks, they'll now be ordered by their identity (and
   omit duplicates, which as mentioned before, I'm not so sure happens
   in practice). I figure no one is bothered by this, but it's a
   difference!
@fakemonster fakemonster changed the title Jt/disk slot Add sled slot to disks in externals /hardware/disks endpoint Sep 2, 2026
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.

physical disks should know which slot they're in

1 participant