Skip to content
Open
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
16 changes: 10 additions & 6 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"downstairs",
"downstairs-api",
"downstairs-types",
"downstairs-types/versions",
"dropshot-apis",
"dsc",
"dsc-client",
Expand Down Expand Up @@ -153,6 +154,7 @@ crucible-control-client = { path = "./control-client" }
crucible-downstairs = { path = "./downstairs" }
crucible-downstairs-api = { path = "./downstairs-api" }
crucible-downstairs-types = { path = "./downstairs-types" }
crucible-downstairs-types-versions = { path = "./downstairs-types/versions" }
crucible-pantry = { path = "./pantry" }
crucible-pantry-api = { path = "./pantry-api" }
crucible-pantry-client = { path = "./pantry-client" }
Expand Down
5 changes: 1 addition & 4 deletions downstairs-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ rust-version = "1.85"

[dependencies]
crucible-common.workspace = true
crucible-downstairs-types.workspace = true
crucible-downstairs-types-versions.workspace = true
crucible-workspace-hack.workspace = true
dropshot.workspace = true
dropshot-api-manager-types.workspace = true
hyper.workspace = true
schemars.workspace = true
serde.workspace = true
uuid.workspace = true
48 changes: 10 additions & 38 deletions downstairs-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
//! API traits for Crucible downstairs operations.

use crucible_common::RegionDefinition;
use crucible_downstairs_types::{FileType, RunDownstairsForRegionParams};
use crucible_downstairs_types_versions::latest;
use dropshot::{
Body, HttpError, HttpResponseCreated, HttpResponseOk, Path, RequestContext,
TypedBody,
};
use dropshot_api_manager_types::api_versions;
use hyper::Response;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

api_versions!([
// WHEN CHANGING THE API (part 1 of 2):
Expand Down Expand Up @@ -53,9 +50,12 @@ pub trait CrucibleDownstairsAdminApi {
}]
async fn run_downstairs_for_region(
rqctx: RequestContext<Self::Context>,
path_param: Path<RunDownstairsForRegionPath>,
run_params: TypedBody<RunDownstairsForRegionParams>,
) -> Result<HttpResponseCreated<DownstairsRunningResponse>, HttpError>;
path_param: Path<latest::admin::RunDownstairsForRegionPath>,
run_params: TypedBody<latest::admin::RunDownstairsForRegionParams>,
) -> Result<
HttpResponseCreated<latest::admin::DownstairsRunningResponse>,
HttpError,
>;
}

/// API trait for the downstairs repair server.
Expand All @@ -70,7 +70,7 @@ pub trait CrucibleDownstairsRepairApi {
}]
async fn get_extent_file(
rqctx: RequestContext<Self::Context>,
path: Path<ExtentFilePath>,
path: Path<latest::repair::ExtentFilePath>,
) -> Result<Response<Body>, HttpError>;

/// Return true if the provided extent is closed or the region is read only.
Expand All @@ -80,7 +80,7 @@ pub trait CrucibleDownstairsRepairApi {
}]
async fn extent_repair_ready(
rqctx: RequestContext<Self::Context>,
path: Path<ExtentPath>,
path: Path<latest::repair::ExtentPath>,
) -> Result<HttpResponseOk<bool>, HttpError>;

/// Get the list of files related to an extent.
Expand All @@ -93,7 +93,7 @@ pub trait CrucibleDownstairsRepairApi {
}]
async fn get_files_for_extent(
rqctx: RequestContext<Self::Context>,
path: Path<ExtentPath>,
path: Path<latest::repair::ExtentPath>,
) -> Result<HttpResponseOk<Vec<String>>, HttpError>;

/// Return the RegionDefinition describing our region.
Expand Down Expand Up @@ -123,31 +123,3 @@ pub trait CrucibleDownstairsRepairApi {
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<bool>, HttpError>;
}

// Admin API types
#[derive(Deserialize, JsonSchema)]
pub struct RunDownstairsForRegionPath {
pub uuid: Uuid,
}

#[derive(Serialize, JsonSchema)]
pub struct DownstairsRunningResponse {
pub uuid: Uuid,
}

// Repair API types
#[derive(Deserialize, JsonSchema)]
pub struct ExtentPath {
pub eid: u32,
}

#[derive(Deserialize, JsonSchema)]
pub struct ExtentFilePath {
pub eid: u32,
pub file_type: FileType,
}

#[derive(Deserialize, JsonSchema)]
pub struct JobPath {
pub id: String,
}
7 changes: 1 addition & 6 deletions downstairs-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,5 @@ edition = "2024"
rust-version = "1.85"

[dependencies]
crucible-common.workspace = true
crucible-downstairs-types-versions.workspace = true
crucible-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true

[dev-dependencies]
serde_json.workspace = true
3 changes: 3 additions & 0 deletions downstairs-types/src/admin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2026 Oxide Computer Company

pub use crucible_downstairs_types_versions::latest::admin::*;
46 changes: 3 additions & 43 deletions downstairs-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,4 @@
// Copyright 2025 Oxide Computer Company
// Copyright 2026 Oxide Computer Company

use std::net::{IpAddr, SocketAddr};
use std::path::PathBuf;

use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum FileType {
#[serde(rename = "data")]
Data,
#[serde(rename = "db")]
Database,
#[serde(rename = "db_shm")]
DatabaseSharedMemory,
#[serde(rename = "db_wal")]
DatabaseLog,
}

#[derive(Deserialize, JsonSchema)]
pub struct FileSpec {
pub eid: u32,
pub file_type: FileType,
}

// Admin API types
#[derive(Deserialize, JsonSchema)]
pub struct RunDownstairsForRegionParams {
pub address: IpAddr,
pub data: PathBuf,
pub oximeter: Option<SocketAddr>,
pub lossy: bool,
pub port: u16,
pub rport: u16,
pub read_errors: bool,
pub write_errors: bool,
pub flush_errors: bool,
pub cert_pem: Option<String>,
pub key_pem: Option<String>,
pub root_cert_pem: Option<String>,
pub read_only: bool,
}
pub mod admin;
pub mod repair;
3 changes: 3 additions & 0 deletions downstairs-types/src/repair.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2026 Oxide Computer Company

pub use crucible_downstairs_types_versions::latest::repair::*;
11 changes: 11 additions & 0 deletions downstairs-types/versions/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "crucible-downstairs-types-versions"
version = "0.1.0"
license = "MPL-2.0"
edition = "2024"

[dependencies]
crucible-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true
uuid.workspace = true
6 changes: 6 additions & 0 deletions downstairs-types/versions/src/impls/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2026 Oxide Computer Company

//! Functional code for the latest versions of types.

// Currently a placeholder. Remove this comment when functional code is added in
// a submodule.
35 changes: 35 additions & 0 deletions downstairs-types/versions/src/initial/admin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2026 Oxide Computer Company

use std::net::{IpAddr, SocketAddr};
use std::path::PathBuf;

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use uuid::Uuid;

#[derive(Deserialize, JsonSchema)]
pub struct RunDownstairsForRegionPath {
pub uuid: Uuid,
}

#[derive(Serialize, JsonSchema)]
pub struct DownstairsRunningResponse {
pub uuid: Uuid,
}

#[derive(Deserialize, JsonSchema)]
pub struct RunDownstairsForRegionParams {
pub address: IpAddr,
pub data: PathBuf,
pub oximeter: Option<SocketAddr>,
pub lossy: bool,
pub port: u16,
pub rport: u16,
pub read_errors: bool,
pub write_errors: bool,
pub flush_errors: bool,
pub cert_pem: Option<String>,
pub key_pem: Option<String>,
pub root_cert_pem: Option<String>,
pub read_only: bool,
}
6 changes: 6 additions & 0 deletions downstairs-types/versions/src/initial/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2026 Oxide Computer Company

//! Version `INITIAL` of the Crucible Downstairs APIs.

pub mod admin;
pub mod repair;
39 changes: 39 additions & 0 deletions downstairs-types/versions/src/initial/repair.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2026 Oxide Computer Company

use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Deserialize, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub enum FileType {
#[serde(rename = "data")]
Data,
#[serde(rename = "db")]
Database,
#[serde(rename = "db_shm")]
DatabaseSharedMemory,
#[serde(rename = "db_wal")]
DatabaseLog,
}

#[derive(Deserialize, JsonSchema)]
pub struct FileSpec {
pub eid: u32,
pub file_type: FileType,
}

#[derive(Deserialize, JsonSchema)]
pub struct ExtentPath {
pub eid: u32,
}

#[derive(Deserialize, JsonSchema)]
pub struct ExtentFilePath {
pub eid: u32,
pub file_type: FileType,
}

#[derive(Deserialize, JsonSchema)]
pub struct JobPath {
pub id: String,
}
15 changes: 15 additions & 0 deletions downstairs-types/versions/src/latest.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2026 Oxide Computer Company

pub mod admin {
pub use crate::v1::admin::DownstairsRunningResponse;
pub use crate::v1::admin::RunDownstairsForRegionParams;
pub use crate::v1::admin::RunDownstairsForRegionPath;
}

pub mod repair {
pub use crate::v1::repair::ExtentFilePath;
pub use crate::v1::repair::ExtentPath;
pub use crate::v1::repair::FileSpec;
pub use crate::v1::repair::FileType;
pub use crate::v1::repair::JobPath;
}
33 changes: 33 additions & 0 deletions downstairs-types/versions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2026 Oxide Computer Company

//! Versioned types for the Crucible Downstairs APIs.
//!
//! # Adding a new API version
//!
//! When adding a new API version N with added or changed types:
//!
//! 1. Create <version_name>/mod.rs, where <version_name> is the lowercase
//! form of the new version's identifier, as defined in the API trait's
//! `api_versions!` macro.
//!
//! 2. Add to the end of this list:
//!
//! ```rust,ignore
//! #[path = "<version_name>/mod.rs"]
//! pub mod vN;
//! ```
//!
//! 3. Add your types to the new module, mirroring the module structure from
//! earlier versions.
//!
//! 4. Update `latest.rs` with new and updated types from the new version.
//!
//! For more information, see the [detailed guide] and [RFD 619].
//!
//! [detailed guide]: https://github.com/oxidecomputer/dropshot-api-manager/blob/main/guides/new-version.md
//! [RFD 619]: https://rfd.shared.oxide.computer/rfd/619

mod impls;
pub mod latest;
#[path = "initial/mod.rs"]
pub mod v1;
5 changes: 4 additions & 1 deletion downstairs/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use super::*;

use anyhow::anyhow;
use crucible_downstairs_api::*;
use crucible_downstairs_types::RunDownstairsForRegionParams;
use crucible_downstairs_types::admin::{
DownstairsRunningResponse, RunDownstairsForRegionParams,
RunDownstairsForRegionPath,
};
use dropshot::{
ClientSpecifiesVersionInHeader, ConfigDropshot, HttpError,
HttpResponseCreated, Path, RequestContext, TypedBody, VersionPolicy,
Expand Down
2 changes: 1 addition & 1 deletion downstairs/src/repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use std::sync::Arc;

use crucible_downstairs_api::*;
use crucible_downstairs_types::FileType;
use crucible_downstairs_types::repair::{ExtentFilePath, ExtentPath, FileType};
use dropshot::{
Body, ConfigDropshot, HandlerTaskMode, HttpError, HttpResponseOk,
HttpServerStarter, Path, RequestContext,
Expand Down