Skip to content

parse_disk_from_request mishandles backend names #750

@gjcolombo

Description

@gjcolombo

I borked this in #743. Relevant code:

pub(super) fn parse_disk_from_request(
disk: &DiskRequest,
) -> Result<ParsedStorageDevice, DeviceRequestError> {
let pci_path = slot_to_pci_path(disk.slot, SlotType::Disk)?;
let device_spec = match disk.device.as_ref() {
"virtio" => StorageDeviceV0::VirtioDisk(VirtioDisk {
backend_name: disk.name.to_string(),
pci_path,
}),
"nvme" => StorageDeviceV0::NvmeDisk(NvmeDisk {
backend_name: disk.name.to_string(),
pci_path,
}),
_ => {
return Err(DeviceRequestError::InvalidStorageInterface(
disk.device.clone(),
disk.slot.0,
))
}
};
let device_name = disk.name.clone();
let backend_name = format!("{}-backend", disk.name);
let backend_spec = StorageBackendV0::Crucible(CrucibleStorageBackend {
request_json: serde_json::to_string(&disk.volume_construction_request)
.map_err(|e| {
DeviceRequestError::SerializationError(disk.name.clone(), e)
})?,
readonly: disk.read_only,
});
Ok(ParsedStorageDevice {
device_name,
device_spec,
backend_name,
backend_spec,
})
}

The previous version of this code used to generate the backend name up front and then use it throughout the routine, i.e., what is now on line 94 of the snippet was actually up at line 75. This breaks disk request processing because the disk devices no longer point to the registered backends.

The completed instance spec refactor will help to avoid this problem by having just one collection for disk device/backend pairs instead of distinct collections for devices and backends. For now we need a fix to unblock the metrics work we merged in #746.

Metadata

Metadata

Assignees

Labels

serverRelated specifically to the Propolis server API and its VM management functions.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions