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

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,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.0"
steno = "0.5.0-dev"
strum = { version = "0.26", features = [ "derive" ] }
subprocess = "0.2.9"
supports-color = "3.0.0"
Expand Down Expand Up @@ -678,8 +678,8 @@ opt-level = 3
#
#[patch."https://github.com/oxidecomputer/dropshot"]
#dropshot = { path = "../dropshot/dropshot" }
#[patch.crates-io]
#steno = { path = "../steno" }
[patch.crates-io]
steno = { path = "../steno-errors" }
#[patch."https://github.com/oxidecomputer/propolis"]
#propolis-client = { path = "../propolis/lib/propolis-client" }
#propolis-mock-server = { path = "../propolis/bin/mock-server" }
Expand Down
44 changes: 30 additions & 14 deletions nexus/src/app/sagas/disk_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::{
use crate::app::sagas::declare_saga_actions;
use crate::app::{authn, authz, db};
use crate::external_api::params;
use anyhow::Context;
use nexus_db_queries::db::identity::{Asset, Resource};
use nexus_db_queries::db::lookup::LookupPath;
use omicron_common::api::external::DiskState;
Expand All @@ -26,6 +27,7 @@ use std::convert::TryFrom;
use std::net::SocketAddrV6;
use steno::ActionError;
use steno::Node;
use steno::UndoActionPermanentError;
use uuid::Uuid;

// disk create saga: input parameters
Expand Down Expand Up @@ -218,7 +220,7 @@ async fn sdc_create_disk_record(

async fn sdc_create_disk_record_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();

let disk_id = sagactx.lookup::<Uuid>("disk_id")?;
Expand All @@ -228,7 +230,9 @@ async fn sdc_create_disk_record_undo(
&disk_id,
&[DiskState::Detached, DiskState::Faulted, DiskState::Creating],
)
.await?;
.await
.context("project_delete_disk_no_auth")
.map_err(UndoActionPermanentError::from)?;
Ok(())
}

Expand Down Expand Up @@ -273,7 +277,7 @@ async fn sdc_alloc_regions(

async fn sdc_alloc_regions_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();
let log = osagactx.log();

Expand All @@ -285,7 +289,12 @@ async fn sdc_alloc_regions_undo(
.map(|(_, region)| region.id())
.collect::<Vec<Uuid>>();

osagactx.datastore().regions_hard_delete(log, region_ids).await?;
osagactx
.datastore()
.regions_hard_delete(log, region_ids)
.await
.context("regions_hard_delete")
.map_err(UndoActionPermanentError::from)?;
Ok(())
}

Expand Down Expand Up @@ -315,7 +324,7 @@ async fn sdc_account_space(

async fn sdc_account_space_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();
let params = sagactx.saga_params::<Params>()?;

Expand All @@ -333,7 +342,7 @@ async fn sdc_account_space_undo(
disk_created.size,
)
.await
.map_err(ActionError::action_failed)?;
.context("virtual_provisioning_collection_delete_disk")?;
Ok(())
}

Expand Down Expand Up @@ -542,7 +551,7 @@ async fn sdc_regions_ensure(

async fn sdc_regions_ensure_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let log = sagactx.user_data().log();
let params = sagactx.saga_params::<Params>()?;
let osagactx = sagactx.user_data();
Expand All @@ -562,7 +571,8 @@ async fn sdc_regions_ensure_undo(
"datasets_and_regions",
)?,
)
.await;
.await
.context("delete_crucible_regions");

match result {
Err(e) => {
Expand All @@ -578,15 +588,16 @@ async fn sdc_regions_ensure_undo(
.disk_id(disk_id)
.fetch_for(authz::Action::Modify)
.await
.map_err(ActionError::action_failed)?;
.context("lookup disk")?;

datastore
.disk_update_runtime(
&opctx,
&authz_disk,
&db_disk.runtime().faulted(),
)
.await?;
.await
.context("disk_update_runtime")?;

return Err(e.into());
}
Expand Down Expand Up @@ -620,7 +631,7 @@ async fn sdc_create_volume_record(

async fn sdc_create_volume_record_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();

let volume_id = sagactx.lookup::<Uuid>("volume_id")?;
Expand All @@ -630,9 +641,14 @@ async fn sdc_create_volume_record_undo(
osagactx
.datastore()
.decrease_crucible_resource_count_and_soft_delete_volume(volume_id)
.await?;
.await
.context("decrease_crucible_resource_count_and_soft_delete_volume")?;

osagactx.datastore().volume_hard_delete(volume_id).await?;
osagactx
.datastore()
.volume_hard_delete(volume_id)
.await
.context("volume_hard_delete")?;

Ok(())
}
Expand Down Expand Up @@ -758,7 +774,7 @@ async fn sdc_call_pantry_attach_for_disk(

async fn sdc_call_pantry_attach_for_disk_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let log = sagactx.user_data().log();
let disk_id = sagactx.lookup::<Uuid>("disk_id")?;

Expand Down
5 changes: 3 additions & 2 deletions nexus/src/app/sagas/disk_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use serde::Deserialize;
use serde::Serialize;
use steno::ActionError;
use steno::Node;
use steno::UndoActionPermanentError;
use uuid::Uuid;

// disk delete saga: input parameters
Expand Down Expand Up @@ -117,7 +118,7 @@ async fn sdd_delete_disk_record(

async fn sdd_delete_disk_record_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();
let params = sagactx.saga_params::<Params>()?;

Expand Down Expand Up @@ -156,7 +157,7 @@ async fn sdd_account_space(

async fn sdd_account_space_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let osagactx = sagactx.user_data();
let params = sagactx.saga_params::<Params>()?;

Expand Down
3 changes: 2 additions & 1 deletion nexus/src/app/sagas/finalize_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use serde::Serialize;
use std::net::SocketAddrV6;
use steno::ActionError;
use steno::Node;
use steno::UndoActionPermanentError;
use uuid::Uuid;

#[derive(Debug, Deserialize, Serialize)]
Expand Down Expand Up @@ -184,7 +185,7 @@ async fn sfd_set_finalizing_state(

async fn sfd_set_finalizing_state_undo(
sagactx: NexusActionContext,
) -> Result<(), anyhow::Error> {
) -> Result<(), UndoActionPermanentError> {
let log = sagactx.user_data().log();
let osagactx = sagactx.user_data();
let params = sagactx.saga_params::<Params>()?;
Expand Down
Loading