Skip to content

Commit

Permalink
Update crucible with new Volume and VCR related changes
Browse files Browse the repository at this point in the history
New crucible, which has updated Volume structure with Logger field.
New VolumeConstructionRequest format which has sub-structures for
all the fields.

This also adds support for the VCR replacement, which can be used
to replace a downstairs as well as validate a VCR for migration.
  • Loading branch information
Alan Hanson committed Aug 10, 2023
1 parent f2f0ad2 commit 0cd0f4b
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 66 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ chrono = "0.4.19"
clap = "4.2"
const_format = "0.2"
crossbeam-channel = "0.5"
crucible = { git = "https://github.com/oxidecomputer/crucible", rev = "84507ed89aced20920de73342666a8abcb8237c1" }
crucible-client-types = { git = "https://github.com/oxidecomputer/crucible", rev = "84507ed89aced20920de73342666a8abcb8237c1" }
crucible = { git = "https://github.com/oxidecomputer/crucible", rev = "b5949e169277d657e32fdfb95d5affb2cb497e86" }
crucible-client-types = { git = "https://github.com/oxidecomputer/crucible", rev = "b5949e169277d657e32fdfb95d5affb2cb497e86" }
ctrlc = "3.2"
dropshot = { git = "https://github.com/oxidecomputer/dropshot", branch = "main" }
enum-iterator = "1.4.1"
Expand Down Expand Up @@ -143,4 +143,3 @@ tracing-subscriber = "0.3.14"
usdt = { version = "0.3.5", default-features = false }
uuid = "1.3.2"
vte = "0.10.1"

28 changes: 16 additions & 12 deletions bin/propolis-server/src/lib/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use propolis::hw::{nvme, virtio};
use propolis::instance::Instance;
use propolis::inventory::{self, EntityID, Inventory};
use propolis::vmm::{self, Builder, Machine};
use propolis_client::handmade::api::{VcrFile, VcrRegion, VcrUrl, VcrVolume};
use propolis_client::instance_spec::{self, *};
use slog::info;

Expand Down Expand Up @@ -312,18 +313,21 @@ impl<'a> MachineInitializer<'a> {
"Creating Crucible disk from request {:?}", req
);
let cru_id = match req {
VolumeConstructionRequest::Volume {
id, ..
} => id.to_string(),
VolumeConstructionRequest::File { id, .. } => {
id.to_string()
}
VolumeConstructionRequest::Url { id, .. } => {
id.to_string()
}
VolumeConstructionRequest::Region { .. } => {
"Region".to_string()
}
VolumeConstructionRequest::Volume(VcrVolume {
id,
..
}) => id.to_string(),
VolumeConstructionRequest::File(VcrFile {
id,
..
}) => id.to_string(),
VolumeConstructionRequest::Url(VcrUrl {
id,
..
}) => id.to_string(),
VolumeConstructionRequest::Region(VcrRegion {
..
}) => "Region".to_string(),
};
let be = propolis::block::CrucibleBackend::create(
req.clone(),
Expand Down
22 changes: 12 additions & 10 deletions bin/propolis-server/src/lib/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ impl ServerSpecBuilder {
mod test {
use std::{collections::BTreeMap, path::PathBuf};

use propolis_client::handmade::api::Slot;
use propolis_client::handmade::api::{Slot, VcrFile};
use uuid::Uuid;

use crate::config::{self, Config};
Expand Down Expand Up @@ -583,11 +583,13 @@ mod test {
slot: Slot(0),
read_only: true,
device: "nvme".to_string(),
volume_construction_request: VolumeConstructionRequest::File {
id: Uuid::new_v4(),
block_size: 512,
path: "disk1.img".to_string()
},
volume_construction_request: VolumeConstructionRequest::File(
VcrFile {
id: Uuid::new_v4(),
block_size: 512,
path: "disk1.img".to_string()
}
),
})
.is_ok());
assert!(matches!(
Expand All @@ -598,11 +600,11 @@ mod test {
read_only: true,
device: "virtio".to_string(),
volume_construction_request:
VolumeConstructionRequest::File {
VolumeConstructionRequest::File(VcrFile {
id: Uuid::new_v4(),
block_size: 512,
path: "disk2.img".to_string()
},
}),
})
.err(),
Some(ServerSpecBuilderError::InnerBuilderError(
Expand Down Expand Up @@ -637,11 +639,11 @@ mod test {
read_only: true,
device: "virtio-scsi".to_string(),
volume_construction_request:
VolumeConstructionRequest::File {
VolumeConstructionRequest::File(VcrFile {
id: Uuid::new_v4(),
block_size: 512,
path: "disk3.img".to_string()
},
}),
})
.err(),
Some(ServerSpecBuilderError::UnrecognizedStorageDevice(_))
Expand Down
4 changes: 3 additions & 1 deletion lib/propolis-client/src/handmade/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use std::net::SocketAddr;
use uuid::Uuid;

// Re-export types that are of a public struct
pub use crucible_client_types::VolumeConstructionRequest;
pub use crucible_client_types::{
VcrFile, VcrRegion, VcrUrl, VcrVolume, VolumeConstructionRequest,
};

#[derive(Clone, Deserialize, Serialize, JsonSchema)]
pub struct InstanceNameParams {
Expand Down
18 changes: 10 additions & 8 deletions lib/propolis-client/src/instance_spec/openapi_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,39 +184,40 @@ impl From<PciPath> for api::PciPath {

use crate::types::VolumeConstructionRequest as GenVCR;
use crucible_client_types::VolumeConstructionRequest as CrucibleVCR;
use crucible_client_types::{VcrFile, VcrRegion, VcrUrl, VcrVolume};

impl From<CrucibleVCR> for GenVCR {
fn from(vcr: CrucibleVCR) -> Self {
match vcr {
CrucibleVCR::Volume {
CrucibleVCR::Volume(VcrVolume {
id,
block_size,
sub_volumes,
read_only_parent,
} => GenVCR::Volume {
}) => GenVCR::Volume {
id,
block_size,
sub_volumes: sub_volumes.into_iter().map(Into::into).collect(),
read_only_parent: read_only_parent
.map(|rop| Box::new((*rop).into())),
},
CrucibleVCR::Url { id, block_size, url } => {
CrucibleVCR::Url(VcrUrl { id, block_size, url }) => {
GenVCR::Url { id, block_size, url }
}
CrucibleVCR::Region {
CrucibleVCR::Region(VcrRegion {
block_size,
blocks_per_extent,
extent_count,
opts,
gen,
} => GenVCR::Region {
}) => GenVCR::Region {
block_size,
blocks_per_extent,
extent_count,
opts: opts.into(),
gen,
},
CrucibleVCR::File { id, block_size, path } => {
CrucibleVCR::File(VcrFile { id, block_size, path }) => {
GenVCR::File { id, block_size, path }
}
}
Expand Down Expand Up @@ -255,6 +256,7 @@ impl From<crucible_client_types::CrucibleOpts> for crate::types::CrucibleOpts {
#[cfg(test)]
mod tests {
use super::*;
use crucible_client_types::VcrRegion;

#[test]
fn device_specs_are_convertible() {
Expand All @@ -270,7 +272,7 @@ mod tests {
"disk1_be".to_string(),
StorageBackend {
kind: StorageBackendKind::Crucible {
req: VolumeConstructionRequest::Region {
req: VolumeConstructionRequest::Region(VcrRegion {
block_size: 512,
blocks_per_extent: 20,
extent_count: 40,
Expand All @@ -287,7 +289,7 @@ mod tests {
read_only: true,
},
gen: 1,
},
}),
},
readonly: true,
},
Expand Down
5 changes: 2 additions & 3 deletions lib/propolis/src/block/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ impl CrucibleBackend {
) -> Result<Arc<Self>, crucible::CrucibleError> {
// Construct the volume.
let volume =
Volume::construct(request, producer_registry, Some(log.clone()))
.await?;
Volume::construct(request, producer_registry, log.clone()).await?;

// Decide if we need to scrub this volume or not.
if volume.has_read_only_parent() {
Expand All @@ -72,7 +71,7 @@ impl CrucibleBackend {
let volume_id = vclone.get_uuid().await.unwrap();

// This does the actual scrub.
match vclone.scrub(&log, Some(120), Some(25)).await {
match vclone.scrub(Some(120), Some(25)).await {
Ok(()) => {
if let Some(nexus_client) = nexus_client {
info!(
Expand Down
56 changes: 31 additions & 25 deletions phd-tests/framework/src/disk/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use std::{
sync::atomic::{AtomicU64, Ordering},
};

use crucible_client_types::{CrucibleOpts, VolumeConstructionRequest};
use crucible_client_types::{
CrucibleOpts, VcrFile, VcrRegion, VcrVolume, VolumeConstructionRequest,
};
use rand::{rngs::StdRng, RngCore, SeedableRng};
use tracing::{error, info};
use uuid::Uuid;
Expand Down Expand Up @@ -240,37 +242,41 @@ impl super::DiskConfig for CrucibleDisk {
propolis_client::instance_spec::StorageBackend {
kind:
propolis_client::instance_spec::StorageBackendKind::Crucible {
req: VolumeConstructionRequest::Volume {
req: VolumeConstructionRequest::Volume(VcrVolume {
id: self.id,
block_size: self.block_size.bytes(),
sub_volumes: vec![VolumeConstructionRequest::Region {
block_size: self.block_size.bytes(),
blocks_per_extent: self.blocks_per_extent,
extent_count: self.extent_count,
opts: CrucibleOpts {
id: Uuid::new_v4(),
target: downstairs_addrs,
lossy: false,
flush_timeout: None,
key: Some(self.encryption_key.clone()),
cert_pem: None,
key_pem: None,
root_cert_pem: None,
control: None,
read_only: false,
sub_volumes: vec![VolumeConstructionRequest::Region(
VcrRegion {
block_size: self.block_size.bytes(),
blocks_per_extent: self.blocks_per_extent,
extent_count: self.extent_count,
opts: CrucibleOpts {
id: Uuid::new_v4(),
target: downstairs_addrs,
lossy: false,
flush_timeout: None,
key: Some(self.encryption_key.clone()),
cert_pem: None,
key_pem: None,
root_cert_pem: None,
control: None,
read_only: false,
},
gen,
},
gen,
}],
)],
read_only_parent: self.read_only_parent.as_ref().map(
|p| {
Box::new(VolumeConstructionRequest::File {
id: Uuid::new_v4(),
block_size: self.block_size.bytes(),
path: p.to_string_lossy().to_string(),
})
Box::new(VolumeConstructionRequest::File(
VcrFile {
id: Uuid::new_v4(),
block_size: self.block_size.bytes(),
path: p.to_string_lossy().to_string(),
},
))
},
),
},
}),
},
readonly: false,
}
Expand Down

0 comments on commit 0cd0f4b

Please sign in to comment.