Skip to content

Commit 590b178

Browse files
committed
fix: don't attempt to free cells if stopping fails on graceful shutdown
1 parent 16649f7 commit 590b178

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

auraed/src/graceful_shutdown.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* SPDX-License-Identifier: Apache-2.0 *
1414
\* -------------------------------------------------------------------------- */
1515

16-
use crate::{cells::CellService, discovery::DiscoveryService, VmService};
16+
use crate::{VmService, cells::CellService, discovery::DiscoveryService};
1717
use proto::{
1818
cells::cell_service_server::CellServiceServer,
1919
discovery::discovery_service_server::DiscoveryServiceServer,
@@ -22,7 +22,7 @@ use proto::{
2222
use std::borrow::BorrowMut;
2323
use tokio::{
2424
signal::unix::SignalKind,
25-
sync::watch::{channel, Receiver, Sender},
25+
sync::watch::{Receiver, Sender, channel},
2626
};
2727
use tonic_health::server::HealthReporter;
2828
use tracing::error;
@@ -86,16 +86,18 @@ impl GracefulShutdown {
8686
// wait for all subscribers to drop
8787
self.shutdown_broadcaster.closed().await;
8888

89+
// Stop and free all cells. Only free if stopping succeeds.
8990
if let Err(e) = self.cell_service.stop_all().await {
90-
error!("Attempt to stop all executables on terminate resulted in error: {e}")
91-
}
92-
93-
if let Err(e) = self.cell_service.free_all().await {
91+
error!(
92+
"Attempt to stop all executables on terminate resulted in error: {e}"
93+
)
94+
} else if let Err(e) = self.cell_service.free_all().await {
9495
error!(
9596
"Attempt to free all cells on terminate resulted in error: {e}"
9697
)
9798
}
9899

100+
// Stop and free all VMs. Always attempt to free even if stopping fails.
99101
if let Err(e) = self.vm_service.stop_all().await {
100102
error!(
101103
"Attempt to stop all VMs on terminate resulted in error: {e}"

0 commit comments

Comments
 (0)