Skip to content

[draft] start decoupling saga code from the rest of Nexus #7999

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

Closed
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
111 changes: 94 additions & 17 deletions Cargo.lock

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

15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ members = [
"nexus/reconfigurator/preparation",
"nexus/reconfigurator/rendezvous",
"nexus/reconfigurator/simulation",
"nexus/saga-interface",
"nexus/saga-recovery",
"nexus/saga-tests",
"nexus/sagas",
"nexus/test-interface",
"nexus/test-utils-macros",
"nexus/test-utils",
Expand Down Expand Up @@ -249,7 +252,10 @@ default-members = [
"nexus/reconfigurator/preparation",
"nexus/reconfigurator/rendezvous",
"nexus/reconfigurator/simulation",
"nexus/saga-interface",
"nexus/saga-recovery",
"nexus/saga-tests",
"nexus/sagas",
"nexus/test-interface",
"nexus/test-utils-macros",
"nexus/test-utils",
Expand Down Expand Up @@ -519,7 +525,10 @@ nexus-reconfigurator-planning = { path = "nexus/reconfigurator/planning" }
nexus-reconfigurator-preparation = { path = "nexus/reconfigurator/preparation" }
nexus-reconfigurator-rendezvous = { path = "nexus/reconfigurator/rendezvous" }
nexus-reconfigurator-simulation = { path = "nexus/reconfigurator/simulation" }
nexus-saga-interface = { path = "nexus/saga-interface" }
nexus-saga-recovery = { path = "nexus/saga-recovery" }
nexus-saga-tests = { path = "nexus/saga-tests" }
nexus-sagas = { path = "nexus/sagas" }
nexus-sled-agent-shared = { path = "nexus-sled-agent-shared" }
nexus-test-interface = { path = "nexus/test-interface" }
nexus-test-utils-macros = { path = "nexus/test-utils-macros" }
Expand Down Expand Up @@ -677,7 +686,7 @@ static_assertions = "1.1.0"
# Please do not change the Steno version to a Git dependency. It makes it
# harder than expected to make breaking changes (even if you specify a specific
# SHA). Cut a new Steno release instead. See omicron#2117.
steno = "0.4.1"
steno = { version = "0.4.2-dev" }
strum = { version = "0.26", features = [ "derive" ] }
subprocess = "0.2.9"
supports-color = "3.0.2"
Expand Down Expand Up @@ -896,13 +905,13 @@ opt-level = 3
# It's common during development to use a local copy of various complex
# dependencies. If you want to use those, uncomment one of these blocks.
#
# [patch.crates-io]
[patch.crates-io]
# diesel = { path = "../../diesel/diesel" }
# dropshot = { path = "../dropshot/dropshot" }
# dropshot_endpoint = { path = "../dropshot/dropshot_endpoint" }
# progenitor = { path = "../progenitor/progenitor" }
# progenitor-client = { path = "../progenitor/progenitor-client" }
# steno = { path = "../steno" }
steno = { git = "https://github.com/oxidecomputer/steno", branch = "sunshowers/spr/draft-add-actioncontextmap_user_data" }

# [patch."https://github.com/oxidecomputer/crucible"]
# crucible-agent-client = { path = "../crucible/agent-client" }
Expand Down
2 changes: 2 additions & 0 deletions nexus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ nexus-external-api.workspace = true
nexus-internal-api.workspace = true
nexus-mgs-updates.workspace = true
nexus-networking.workspace = true
nexus-saga-interface.workspace = true
nexus-saga-recovery.workspace = true
nexus-sagas.workspace = true
nexus-test-interface.workspace = true
num-integer.workspace = true
openssl.workspace = true
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ nexus-db-fixed-data.workspace = true
nexus-db-model.workspace = true
nexus-db-lookup.workspace = true
nexus-db-schema.workspace = true
nexus-saga-interface.workspace = true
nexus-sled-agent-shared.workspace = true
nexus-types.workspace = true
omicron-common.workspace = true
Expand Down
1 change: 1 addition & 0 deletions nexus/db-queries/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ mod pool_connection;
// sagas.
pub mod queries;
mod raw_query_builder;
mod saga_interface;
mod sec_store;
pub(crate) mod true_or_cast_error;
mod update_and_check;
Expand Down
47 changes: 47 additions & 0 deletions nexus/db-queries/src/db/saga_interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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/.

use nexus_auth::authz;
use nexus_auth::context::OpContext;
use nexus_saga_interface::DataStoreImpl;
use omicron_common::api::external::DeleteResult;
use omicron_common::api::external::Error;
use uuid::Uuid;

use super::DataStore;

#[async_trait::async_trait]
impl DataStoreImpl for DataStore {
async fn project_delete_instance(
&self,
opctx: &OpContext,
authz_instance: &authz::Instance,
) -> DeleteResult {
self.project_delete_instance(opctx, authz_instance).await
}

async fn instance_delete_all_network_interfaces(
&self,
opctx: &OpContext,
authz_instance: &authz::Instance,
) -> DeleteResult {
self.instance_delete_all_network_interfaces(opctx, authz_instance).await
}

async fn deallocate_external_ip_by_instance_id(
&self,
opctx: &OpContext,
instance_id: Uuid,
) -> Result<usize, Error> {
self.deallocate_external_ip_by_instance_id(opctx, instance_id).await
}

async fn detach_floating_ips_by_instance_id(
&self,
opctx: &OpContext,
instance_id: Uuid,
) -> Result<usize, Error> {
self.detach_floating_ips_by_instance_id(opctx, instance_id).await
}
}
25 changes: 25 additions & 0 deletions nexus/saga-interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "nexus-saga-interface"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
async-trait.workspace = true
nexus-auth.workspace = true
nexus-background-task-interface.workspace = true
# Note: this crate depends on nexus-db-lookup but not nexus-db-queries, for
# build speed reasons.
nexus-db-lookup.workspace = true
omicron-common.workspace = true
omicron-workspace-hack.workspace = true
paste.workspace = true
serde.workspace = true
serde_json.workspace = true
steno.workspace = true
slog.workspace = true
thiserror.workspace = true
uuid.workspace = true
Loading
Loading