-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store NVMe firmware metadata in inventory collection #6275
Conversation
5d7df4b
to
ded63b4
Compare
Example output from the updated omdb command:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just some general notes on testing and defensiveness!
5c8bf92
to
3e59254
Compare
pub fn current_version(&self) -> Option<&str> { | ||
match self.active_slot.0 { | ||
// be paranoid that we have a value within the NVMe spec | ||
slot @ 1..=7 => self | ||
.slot_firmware_versions | ||
.get(usize::from(slot) - 1) | ||
.and_then(|v| v.as_deref()), | ||
_ => None, | ||
} | ||
} | ||
|
||
/// Attempt to read the staged firmware version that will be active upon | ||
/// next device reset. | ||
pub fn next_version(&self) -> Option<&str> { | ||
match self.next_active_slot { | ||
// be paranoid that we have a value within the NVMe spec | ||
Some(slot) if slot.0 <= 7 && slot.0 >= 1 => self | ||
.slot_firmware_versions | ||
.get(usize::from(slot.0) - 1) | ||
.and_then(|v| v.as_deref()), | ||
_ => None, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks should be unnecessary now that the only way to construct a InvNvmeDiskFirmware
is through the "new" method, but I kind of like the extra safety net. Thoughts on converting this to Result<&str, InvNvmeDiskFirmwareError>
and Result<Option<&str>, InvNvmeDiskFirmwareError>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an Option
is fine -- I'm not sure we'd yet want a caller to treat a Result::Err
case differently from None
anyway.
@@ -1551,3 +1740,218 @@ impl InvOmicronZoneNic { | |||
zone_nic.into_network_interface_for_zone(zone_id) | |||
} | |||
} | |||
|
|||
#[cfg(test)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests, thanks for adding these!
pub fn current_version(&self) -> Option<&str> { | ||
match self.active_slot.0 { | ||
// be paranoid that we have a value within the NVMe spec | ||
slot @ 1..=7 => self | ||
.slot_firmware_versions | ||
.get(usize::from(slot) - 1) | ||
.and_then(|v| v.as_deref()), | ||
_ => None, | ||
} | ||
} | ||
|
||
/// Attempt to read the staged firmware version that will be active upon | ||
/// next device reset. | ||
pub fn next_version(&self) -> Option<&str> { | ||
match self.next_active_slot { | ||
// be paranoid that we have a value within the NVMe spec | ||
Some(slot) if slot.0 <= 7 && slot.0 >= 1 => self | ||
.slot_firmware_versions | ||
.get(usize::from(slot.0) - 1) | ||
.and_then(|v| v.as_deref()), | ||
_ => None, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an Option
is fine -- I'm not sure we'd yet want a caller to treat a Result::Err
case differently from None
anyway.
With #5706 merged and later reenabled in #6026 we now want to store this data in CRDB so that it can be used by blueprints and reconfigurator.
nexus_types::inventory::PhysicalDisk
now has afirmware
field that is exposed as an enum calledPhysicalDiskFirmware
. Today we only haveUnknown
andNvme
variants but this can later be expanded upon if we ever start using additional disk types such as SCSI/SATA etc.Finally I have included an updated version of
omdb db inventory physical-disks
that will include the currently active firmware as well as the next active firmware if a new version has been staged.