From e360daefbf3409b6df795f0e01ca45f543ff4f43 Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Fri, 5 Jul 2024 09:26:34 -0700 Subject: [PATCH] more explicit instance termination --- sled-agent/src/instance_manager.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sled-agent/src/instance_manager.rs b/sled-agent/src/instance_manager.rs index 2701db19ab..f4b2ea5b49 100644 --- a/sled-agent/src/instance_manager.rs +++ b/sled-agent/src/instance_manager.rs @@ -841,7 +841,17 @@ impl InstanceManagerRunner { for id in to_remove { info!(self.log, "only_use_disks: Removing instance"; "instance_id" => ?id); - self.instances.remove(&id); + if let Some((_, instance)) = self.instances.remove(&id) { + let (tx, rx) = oneshot::channel(); + if let Err(e) = instance.terminate(tx).await { + warn!(self.log, "only_use_disks: Failed to request instance removal"; "err" => ?e); + continue; + } + + if let Err(e) = rx.await { + warn!(self.log, "only_use_disks: Failed while removing instance"; "err" => ?e); + } + } } tx.send(Ok(())).map_err(|_| Error::FailedSendClientClosed)?;