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

Add configuration - with defaults - to enable virtualized sled storage #633

Merged
merged 2 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion sled-agent/src/bin/sled-agent-sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ use dropshot::ConfigLogging;
use dropshot::ConfigLoggingLevel;
use omicron_common::cmd::fatal;
use omicron_common::cmd::CmdError;
use omicron_sled_agent::sim::{run_server, Config, SimMode};
use omicron_sled_agent::sim::{
run_server, Config, ConfigStorage, ConfigZpool, SimMode,
};
use std::net::SocketAddr;
use structopt::StructOpt;
use uuid::Uuid;
Expand Down Expand Up @@ -73,6 +75,10 @@ async fn do_run() -> Result<(), CmdError> {
..Default::default()
},
log: ConfigLogging::StderrTerminal { level: ConfigLoggingLevel::Info },
storage: ConfigStorage {
// Create 10 "virtual" U.2s, with 1 TB of storage.
zpools: vec![ConfigZpool { size: 1 << 40 }; 10],
},
};

run_server(&config).await.map_err(CmdError::Failure)
Expand Down
17 changes: 17 additions & 0 deletions sled-agent/src/sim/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ pub enum SimMode {
Explicit,
}

/// Configuration for a simulated zpool.
///
/// Currently, each zpool will receive a single Crucible Dataset.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct ConfigZpool {
/// The size of the Zpool in bytes.
pub size: u64,
}

/// Configuration describing simulated storage.
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
pub struct ConfigStorage {
pub zpools: Vec<ConfigZpool>,
}

/**
* Configuration for a sled agent
*/
Expand All @@ -48,4 +63,6 @@ pub struct Config {
pub dropshot: ConfigDropshot,
/** configuration for the sled agent debug log */
pub log: ConfigLogging,
/** configuration for the sled agent's storage */
pub storage: ConfigStorage,
}
2 changes: 1 addition & 1 deletion sled-agent/src/sim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ mod simulatable;
mod sled_agent;
mod storage;

pub use config::{Config, SimMode};
pub use config::{Config, ConfigStorage, ConfigZpool, SimMode};
pub use server::{run_server, Server};
pub use sled_agent::SledAgent;
10 changes: 10 additions & 0 deletions sled-agent/src/sim/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ impl Server {
.map_err(|error| format!("initializing server: {}", error))?
.start();

// Create all the Zpools requested by the config, and allocate a single
// Crucible dataset for each. This emulates the setup we expect to have
// on the physical rack.
for zpool in &config.storage.zpools {
let zpool_id = uuid::Uuid::new_v4();
sled_agent.create_zpool(zpool_id, zpool.size).await;
let dataset_id = uuid::Uuid::new_v4();
sled_agent.create_crucible_dataset(zpool_id, dataset_id).await;
}

/*
* Notify the control plane that we're up, and continue trying this
* until it succeeds. We retry with an randomized, capped exponential
Expand Down