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

[sim][sled agent] Register storage after sled #645

Merged
merged 2 commits into from
Jan 26, 2022
Merged
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
30 changes: 20 additions & 10 deletions sled-agent/src/sim/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use super::config::Config;
use super::http_entrypoints::api as http_api;
use super::sled_agent::SledAgent;
use crucible_agent_client::types::State as RegionState;

use nexus_client::Client as NexusClient;
use omicron_common::backoff::{
Expand Down Expand Up @@ -66,16 +67,6 @@ 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 Expand Up @@ -108,6 +99,25 @@ impl Server {
)
.await
.expect("Expected an infinite retry loop contacting Nexus");

// 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;

// Whenever Nexus tries to allocate a region, it should complete
// immediately. What efficiency!
let crucible =
sled_agent.get_crucible_dataset(zpool_id, dataset_id).await;
crucible
.set_create_callback(Box::new(|_| RegionState::Created))
.await;
}

Ok(Server { sled_agent, http_server })
}

Expand Down