Skip to content
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

Merged
merged 4 commits into from
Sep 25, 2024

Conversation

papertigers
Copy link
Contributor

@papertigers papertigers commented Aug 8, 2024

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 a firmware field that is exposed as an enum called PhysicalDiskFirmware. Today we only have Unknown and Nvme 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.

@papertigers papertigers force-pushed the mike/nvme-firmware-crdb branch from 5d7df4b to ded63b4 Compare August 12, 2024 20:33
@papertigers
Copy link
Contributor Author

Example output from the updated omdb command:

root@oxz_switch0:~# /var/tmp/omdb db inventory physical-disks --collection-id bfaca60c-94c4-4ff8-9f28-dadf5998c598
INV_COLLECTION_ID                    SLED_ID                              SLOT VENDOR           MODEL              SERIAL             VARIANT FIRMWARE NEXT_FIRMWARE
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1024 synthetic-vendor synthetic-model-M2 synthetic-serial-0 M2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1025 synthetic-vendor synthetic-model-M2 synthetic-serial-1 M2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1026 synthetic-vendor synthetic-model-U2 synthetic-serial-0 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1027 synthetic-vendor synthetic-model-U2 synthetic-serial-1 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1028 synthetic-vendor synthetic-model-U2 synthetic-serial-2 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1029 synthetic-vendor synthetic-model-U2 synthetic-serial-3 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1030 synthetic-vendor synthetic-model-U2 synthetic-serial-4 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1031 synthetic-vendor synthetic-model-U2 synthetic-serial-5 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1032 synthetic-vendor synthetic-model-U2 synthetic-serial-6 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1033 synthetic-vendor synthetic-model-U2 synthetic-serial-7 U2      SYNTH1
bfaca60c-94c4-4ff8-9f28-dadf5998c598 02d60605-625b-4c9f-84cc-fd675aada3e0 1034 synthetic-vendor synthetic-model-U2 synthetic-serial-8 U2      SYNTH1

@papertigers papertigers marked this pull request as ready for review August 12, 2024 20:40
@papertigers papertigers requested a review from smklein August 12, 2024 20:40
schema/crdb/dbinit.sql Outdated Show resolved Hide resolved
Copy link
Collaborator

@smklein smklein left a 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!

schema/crdb/dbinit.sql Show resolved Hide resolved
nexus/db-model/src/inventory.rs Show resolved Hide resolved
nexus/db-model/src/inventory.rs Outdated Show resolved Hide resolved
nexus/db-model/src/inventory.rs Outdated Show resolved Hide resolved
nexus/db-queries/src/db/datastore/inventory.rs Outdated Show resolved Hide resolved
nexus/db-queries/src/db/datastore/inventory.rs Outdated Show resolved Hide resolved
@papertigers papertigers force-pushed the mike/nvme-firmware-crdb branch from 5c8bf92 to 3e59254 Compare September 18, 2024 21:10
nexus/db-queries/src/db/datastore/inventory.rs Outdated Show resolved Hide resolved
schema/crdb/dbinit.sql Show resolved Hide resolved
nexus/db-model/src/inventory.rs Show resolved Hide resolved
nexus/db-model/src/inventory.rs Outdated Show resolved Hide resolved
nexus/db-queries/src/db/datastore/inventory.rs Outdated Show resolved Hide resolved
nexus/db-model/src/inventory.rs Outdated Show resolved Hide resolved
Comment on lines +1012 to 1034
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,
}
}
Copy link
Contributor Author

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>

Copy link
Collaborator

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)]
Copy link
Collaborator

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!

Comment on lines +1012 to 1034
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,
}
}
Copy link
Collaborator

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.

@papertigers papertigers merged commit 356c9bf into main Sep 25, 2024
17 checks passed
@papertigers papertigers deleted the mike/nvme-firmware-crdb branch September 25, 2024 20:10
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.

3 participants