Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ oximeter = { git = "https://github.com/oxidecomputer/omicron", branch = "main" }
sled-agent-client = { git = "https://github.com/oxidecomputer/omicron", branch = "main" }

# Crucible
crucible = { git = "https://github.com/oxidecomputer/crucible", rev = "ae1da83e66c648574827298f4bc444632bf4d047" }
crucible-client-types = { git = "https://github.com/oxidecomputer/crucible", rev = "ae1da83e66c648574827298f4bc444632bf4d047" }
crucible = { git = "https://github.com/oxidecomputer/crucible", rev = "3c1708d86e10f0370807388a1efe092edd99d431" }
crucible-client-types = { git = "https://github.com/oxidecomputer/crucible", rev = "3c1708d86e10f0370807388a1efe092edd99d431" }

# Attestation
dice-verifier = { git = "https://github.com/oxidecomputer/dice-util", rev = "1d3084b514389847e8e0f5d966d2be4f18d02d32", features = ["sled-agent"] }
Expand Down
35 changes: 32 additions & 3 deletions bin/propolis-server/src/lib/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ use propolis_api_types::serial::{
InstanceSerialConsoleHistoryRequest, InstanceSerialConsoleHistoryResponse,
InstanceSerialConsoleStreamRequest,
};
use propolis_api_types_versions::v1::disk::VolumeStatus as VolumeStatusV1;
use propolis_server_api::PropolisServerApi;
use rfb::tungstenite::BinaryWs;
use slog::{error, warn, Logger};
Expand Down Expand Up @@ -557,10 +558,10 @@ impl PropolisServerApi for PropolisServerImpl {
Ok(HttpResponseOk(()))
}

async fn disk_volume_status(
async fn disk_volume_status_v1(
rqctx: RequestContext<Self::Context>,
path_params: Path<VolumeStatusPathParams>,
) -> Result<HttpResponseOk<VolumeStatus>, HttpError> {
) -> Result<HttpResponseOk<VolumeStatusV1>, HttpError> {
let path_params = path_params.into_inner();
let vm = rqctx
.context()
Expand All @@ -578,13 +579,41 @@ impl PropolisServerApi for PropolisServerImpl {
HttpError::for_not_found(Some(s.clone()), s)
})?;

Ok(HttpResponseOk(VolumeStatus {
Ok(HttpResponseOk(VolumeStatusV1 {
active: backend.volume_is_active().await.map_err(|e| {
HttpError::for_bad_request(Some(e.to_string()), e.to_string())
})?,
}))
}

async fn disk_volume_status(
rqctx: RequestContext<Self::Context>,
path_params: Path<VolumeStatusPathParams>,
) -> Result<HttpResponseOk<VolumeStatus>, HttpError> {
let path_params = path_params.into_inner();
let vm = rqctx
.context()
.vm
.active_vm()
.await
.ok_or_else(not_created_error)?;
let objects = vm.objects().lock_shared().await;
let backend = objects
.crucible_backends()
.get(&SpecKey::from(path_params.id.clone()))
.ok_or_else(|| {
let s =
format!("No crucible backend for id {}", path_params.id);
HttpError::for_not_found(Some(s.clone()), s)
})?;

let volume_info = backend.query_volume_info().await.map_err(|e| {
HttpError::for_bad_request(Some(e.to_string()), e.to_string())
})?;

Ok(HttpResponseOk(VolumeStatus { volume_info }))
}

async fn instance_issue_crucible_vcr_request(
rqctx: RequestContext<Self::Context>,
path_params: Path<VCRRequestPathParams>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Disk and volume types for the CRUCIBLE_VOLUME_INFO API version.

use schemars::JsonSchema;
use serde::Serialize;

#[derive(Debug, Serialize, JsonSchema)]
pub struct VolumeStatus {
pub volume_info: crucible_client_types::VolumeInfo,
}
10 changes: 10 additions & 0 deletions crates/propolis-api-types-versions/src/crucible_volume_info/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! Version `CRUCIBLE_VOLUME_INFO` of the Propolis Server API.
//!
//! This version changes the `disk_volume_status` endpoint to use the new
//! VolumeInfo query

pub mod disk;
2 changes: 1 addition & 1 deletion crates/propolis-api-types-versions/src/latest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub mod disk {
pub use crate::v1::disk::InstanceVCRReplace;
pub use crate::v1::disk::SnapshotRequestPathParams;
pub use crate::v1::disk::VCRRequestPathParams;
pub use crate::v1::disk::VolumeStatus;
pub use crate::v1::disk::VolumeStatusPathParams;
pub use crate::v5::disk::VolumeStatus;
}

pub mod instance {
Expand Down
2 changes: 2 additions & 0 deletions crates/propolis-api-types-versions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ pub mod v1;
pub mod v2;
#[path = "add_vsock/mod.rs"]
pub mod v3;
#[path = "crucible_volume_info/mod.rs"]
pub mod v5;
14 changes: 14 additions & 0 deletions crates/propolis-server-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ api_versions!([
// | example for the next person.
// v
// (next_int, IDENT),
(5, CRUCIBLE_VOLUME_INFO),
(4, DROPSHOT_BUMP_WEBSOCKET),
(3, ADD_VSOCK),
(2, PROGRAMMABLE_SMBIOS),
Expand Down Expand Up @@ -266,8 +267,21 @@ pub trait PropolisServerApi {

/// Gets the status of a Crucible volume backing a disk
#[endpoint {
operation_id = "disk_volume_status",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see, disk_volume_status is the automatically-chosen Id for async fn disk_volume_status below, and by setting it explicitly like this we're telling Dropshot that this is a different version of that API rather than a new disk_volume_status_v1? I'm not sure if I'm missing a detail to that, but if so then carry on 🫡

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no you're right - this is done to maintain the operation ID for older versions

method = GET,
path = "/instance/disk/{id}/status",
versions = VERSION_INITIAL..VERSION_CRUCIBLE_VOLUME_INFO,
}]
async fn disk_volume_status_v1(
rqctx: RequestContext<Self::Context>,
path_params: Path<v1::disk::VolumeStatusPathParams>,
) -> Result<HttpResponseOk<v1::disk::VolumeStatus>, HttpError>;

/// Gets the status of a Crucible volume backing a disk
#[endpoint {
method = GET,
path = "/instance/disk/{id}/status",
versions = VERSION_CRUCIBLE_VOLUME_INFO..,
}]
async fn disk_volume_status(
rqctx: RequestContext<Self::Context>,
Expand Down
5 changes: 5 additions & 0 deletions lib/propolis/src/block/crucible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crucible::{
VolumeBuilder,
};
use crucible_client_types::VolumeConstructionRequest;
use crucible_client_types::VolumeInfo;
use oximeter::types::ProducerRegistry;
use slog::{error, info};
use thiserror::Error;
Expand Down Expand Up @@ -371,6 +372,10 @@ impl CrucibleBackend {
pub fn is_read_only(&self) -> bool {
self.state.info.read_only
}

pub async fn query_volume_info(&self) -> Result<VolumeInfo, CrucibleError> {
self.state.volume.query_volume_info().await
}
}

#[async_trait::async_trait]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d9e5dc0d2bb8a185f008a43be9d8131fb9ca3a06:openapi/propolis-server/propolis-server-4.0.0-5ce09a.json
Loading
Loading