diff --git a/implementations/rust/ockam/ockam_app_lib/src/state/mod.rs b/implementations/rust/ockam/ockam_app_lib/src/state/mod.rs index 09240b9d619..d326f60150c 100644 --- a/implementations/rust/ockam/ockam_app_lib/src/state/mod.rs +++ b/implementations/rust/ockam/ockam_app_lib/src/state/mod.rs @@ -27,6 +27,7 @@ use ockam_api::cli_state::{ }; use ockam_api::cloud::enroll::auth0::UserInfo; use ockam_api::cloud::project::Project; +use ockam_api::cloud::space::Spaces; use ockam_api::cloud::{AuthorityNode, Controller}; use ockam_api::nodes::models::portal::OutletStatus; use ockam_api::nodes::models::transport::{CreateTransportJson, TransportMode, TransportType}; @@ -269,6 +270,7 @@ impl AppState { } async fn reset_state(&self) -> miette::Result<()> { + self.reset_orchestrator().await?; let mut state = self.state.write().await; match state.reset().await { Ok(s) => { @@ -280,6 +282,17 @@ impl AppState { Ok(()) } + async fn reset_orchestrator(&self) -> miette::Result<()> { + let ctx = self.context(); + let controller = self.controller().await?; + for space in self.state().await.spaces.list()? { + controller + .delete_space(&ctx, space.config().id.clone()) + .await?; + } + Ok(()) + } + /// Recreate a new NodeManagerWorker instance, which will restart the necessary /// child workers as described in its Worker trait implementation. pub async fn reset_node_manager(&self) -> miette::Result<()> {