Skip to content

Commit

Permalink
move blueprint execution to its own package (#4963)
Browse files Browse the repository at this point in the history
  • Loading branch information
davepacheco authored Feb 2, 2024
1 parent 966a87e commit ed2e63b
Show file tree
Hide file tree
Showing 9 changed files with 530 additions and 199 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ members = [
"key-manager",
"nexus",
"nexus/authz-macros",
"nexus/blueprint-execution",
"nexus/db-macros",
"nexus/db-model",
"nexus/db-queries",
Expand Down Expand Up @@ -113,6 +114,7 @@ default-members = [
"key-manager",
"nexus",
"nexus/authz-macros",
"nexus/blueprint-execution",
"nexus/db-macros",
"nexus/db-model",
"nexus/db-queries",
Expand Down Expand Up @@ -246,6 +248,7 @@ mime_guess = "2.0.4"
mockall = "0.12"
newtype_derive = "0.1.6"
mg-admin-client = { path = "clients/mg-admin-client" }
nexus-blueprint-execution = { path = "nexus/blueprint-execution" }
nexus-client = { path = "clients/nexus-client" }
nexus-db-model = { path = "nexus/db-model" }
nexus-db-queries = { path = "nexus/db-queries" }
Expand Down
1 change: 1 addition & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ tough.workspace = true
trust-dns-resolver.workspace = true
uuid.workspace = true

nexus-blueprint-execution.workspace = true
nexus-defaults.workspace = true
nexus-db-model.workspace = true
nexus-db-queries.workspace = true
Expand Down
34 changes: 34 additions & 0 deletions nexus/blueprint-execution/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "nexus-blueprint-execution"
version = "0.1.0"
edition = "2021"

[build-dependencies]
omicron-rpaths.workspace = true

[dependencies]
anyhow.workspace = true
futures.workspace = true
nexus-db-queries.workspace = true
nexus-types.workspace = true
reqwest.workspace = true
sled-agent-client.workspace = true
slog.workspace = true
uuid.workspace = true

# See omicron-rpaths for more about the "pq-sys" dependency. This is needed
# because we use the database in the test suite, though it doesn't appear to
# work to put the pq-sys dependency only in dev-dependencies.
pq-sys = "*"

omicron-workspace-hack.workspace = true

[dev-dependencies]
chrono.workspace = true
httptest.workspace = true
nexus-db-model.workspace = true
nexus-test-utils.workspace = true
nexus-test-utils-macros.workspace = true
omicron-common.workspace = true
omicron-nexus.workspace = true
tokio.workspace = true
10 changes: 10 additions & 0 deletions nexus/blueprint-execution/build.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/.

// See omicron-rpaths for documentation.
// NOTE: This file MUST be kept in sync with the other build.rs files in this
// repository.
fn main() {
omicron_rpaths::configure_default_omicron_rpaths();
}
34 changes: 34 additions & 0 deletions nexus/blueprint-execution/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 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/.

//! Execution of Nexus blueprints
//!
//! See `nexus_deployment` crate-level docs for background.
use nexus_db_queries::context::OpContext;
use nexus_db_queries::db::DataStore;
use nexus_types::deployment::Blueprint;
use slog::o;

mod omicron_zones;

/// Make one attempt to realize the given blueprint, meaning to take actions to
/// alter the real system to match the blueprint
///
/// The assumption is that callers are running this periodically or in a loop to
/// deal with transient errors or changes in the underlying system state.
pub async fn realize_blueprint(
opctx: &OpContext,
datastore: &DataStore,
blueprint: &Blueprint,
) -> Result<(), Vec<anyhow::Error>> {
let log = opctx.log.new(o!("comment" => blueprint.comment.clone()));
omicron_zones::deploy_zones(
&log,
opctx,
datastore,
&blueprint.omicron_zones,
)
.await
}
Loading

0 comments on commit ed2e63b

Please sign in to comment.