Skip to content

Commit 5c91745

Browse files
committed
feat: Add graceful shutdown
1 parent f5026f5 commit 5c91745

5 files changed

Lines changed: 43 additions & 33 deletions

File tree

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2024"
1010
repository = "https://github.com/stackabletech/opensearch-operator"
1111

1212
[workspace.dependencies]
13-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.102.0", features = ["telemetry", "versioned"] }
13+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.105.0", features = ["telemetry", "versioned"] }
1414

1515
built = { version = "0.8.0", features = ["chrono", "git2"] }
1616
clap = "4.5"

crate-hashes.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/operator-binary/src/main.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use stackable_operator::{
2727
logging::controller::report_controller_reconciled,
2828
shared::yaml::SerializeOptions,
2929
telemetry::Tracing,
30+
utils::signal::SignalWatcher,
3031
};
3132
use strum::{EnumDiscriminants, IntoStaticStr};
3233

@@ -68,6 +69,11 @@ pub enum Error {
6869
CreateClient {
6970
source: stackable_operator::client::Error,
7071
},
72+
73+
#[snafu(display("failed to create SIGTERM signal watcher"))]
74+
CreateSignalWatcher {
75+
source: stackable_operator::utils::signal::SignalError,
76+
},
7177
}
7278

7379
#[derive(clap::Parser)]
@@ -109,10 +115,14 @@ async fn main() -> Result<()> {
109115
description = built_info::PKG_DESCRIPTION
110116
);
111117

118+
// Watches for the SIGTERM signal and sends a signal to all receivers, which gracefully
119+
// shuts down all concurrent tasks below (EoS checker, controller).
120+
let sigterm_watcher = SignalWatcher::sigterm().context(CreateSignalWatcherSnafu)?;
121+
112122
let eos_checker =
113123
EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)
114124
.context(InitEndOfSupportCheckerSnafu)?
115-
.run()
125+
.run(sigterm_watcher.handle())
116126
.map(Ok);
117127

118128
let operator_name = OperatorName::from_str("opensearch.stackable.tech")
@@ -168,7 +178,7 @@ async fn main() -> Result<()> {
168178
watch_namespace.get_api::<DeserializeGuard<StatefulSet>>(&client),
169179
watcher::Config::default(),
170180
)
171-
.shutdown_on_signal()
181+
.graceful_shutdown_on(sigterm_watcher.handle())
172182
.run(
173183
controller::reconcile,
174184
controller::error_policy,

0 commit comments

Comments
 (0)