From d63ceb9520afb34c1d6567b763fccbb7767dbfef Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 26 Jul 2024 16:29:42 -0700 Subject: [PATCH] bit less overengineered --- sled-agent/src/instance.rs | 32 +++++++++++--------------------- sled-agent/src/sled_agent.rs | 16 +++++++++------- sled-agent/src/zone_bundle.rs | 4 ++-- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/sled-agent/src/instance.rs b/sled-agent/src/instance.rs index 6d499368ce..8bafad8b6b 100644 --- a/sled-agent/src/instance.rs +++ b/sled-agent/src/instance.rs @@ -132,18 +132,8 @@ pub enum Error { #[error("Instance dropped our request")] RequestDropped(#[from] oneshot::error::RecvError), - #[error(transparent)] - Terminating(#[from] Terminating), -} - -#[derive(thiserror::Error, Debug)] -#[error("Instance is terminating")] -pub struct Terminating(()); - -impl From for ManagerError { - fn from(t: Terminating) -> Self { - Self::Instance(t.into()) - } + #[error("Instance is terminating")] + Terminating, } // Issues read-only, idempotent HTTP requests at propolis until it responds with @@ -501,30 +491,30 @@ impl InstanceRunner { // instead of bailing out, since we still need to drain the rest of // the queue, let _ = match request { - RequestZoneBundle { tx } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) - } + RequestZoneBundle { tx } => tx + .send(Err(BundleError::InstanceTerminating)) + .map_err(|_| ()), GetFilesystemPool { tx } => tx.send(None).map_err(|_| ()), CurrentState { tx } => { tx.send(self.current_state()).map_err(|_| ()) } PutState { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } PutMigrationIds { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } Terminate { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } IssueSnapshotRequest { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } AddExternalIp { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } DeleteExternalIp { tx, .. } => { - tx.send(Err(Terminating(()).into())).map_err(|_| ()) + tx.send(Err(Error::Terminating.into())).map_err(|_| ()) } }; } diff --git a/sled-agent/src/sled_agent.rs b/sled-agent/src/sled_agent.rs index 8ccec4c174..163a8c356e 100644 --- a/sled-agent/src/sled_agent.rs +++ b/sled-agent/src/sled_agent.rs @@ -212,11 +212,11 @@ impl From for dropshot::HttpError { // Progenitor client error it gets back. HttpError::from(omicron_error) } - crate::instance::Error::Terminating(t) => { + crate::instance::Error::Terminating => { HttpError::for_client_error( Some(NO_SUCH_INSTANCE.to_string()), http::StatusCode::GONE, - t.to_string(), + instance_error.to_string(), ) } e => HttpError::for_internal_error(e.to_string()), @@ -239,11 +239,13 @@ impl From for dropshot::HttpError { | BundleError::InvalidCleanupPeriod => { HttpError::for_bad_request(None, inner.to_string()) } - BundleError::Terminating(t) => HttpError::for_client_error( - Some(NO_SUCH_INSTANCE.to_string()), - http::StatusCode::GONE, - t.to_string(), - ), + BundleError::InstanceTerminating => { + HttpError::for_client_error( + Some(NO_SUCH_INSTANCE.to_string()), + http::StatusCode::GONE, + inner.to_string(), + ) + } _ => HttpError::for_internal_error(err.to_string()), }, e => HttpError::for_internal_error(e.to_string()), diff --git a/sled-agent/src/zone_bundle.rs b/sled-agent/src/zone_bundle.rs index e3a998982b..4062016597 100644 --- a/sled-agent/src/zone_bundle.rs +++ b/sled-agent/src/zone_bundle.rs @@ -692,8 +692,8 @@ pub enum BundleError { #[error("Failed to get ZFS property value")] GetProperty(#[from] GetValueError), - #[error(transparent)] - Terminating(#[from] crate::instance::Terminating), + #[error("Instance is terminating")] + InstanceTerminating, } // Helper function to write an array of bytes into the tar archive, with