Skip to content

Commit 695f6c9

Browse files
committed
feat: Add graceful shutdown
1 parent 807779e commit 695f6c9

5 files changed

Lines changed: 38 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
@@ -11,7 +11,7 @@ repository = "https://github.com/stackabletech/hdfs-operator"
1111

1212
[workspace.dependencies]
1313
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.8.0" }
14-
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.102.0", features = ["telemetry", "versioned"] }
14+
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.105.0", features = ["telemetry", "versioned"] }
1515

1616
anyhow = "1.0"
1717
built = { version = "0.8", features = ["chrono", "git2"] }

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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use stackable_operator::{
3030
logging::controller::report_controller_reconciled,
3131
shared::yaml::SerializeOptions,
3232
telemetry::Tracing,
33+
utils::signal::SignalWatcher,
3334
};
3435
use tracing::info_span;
3536
use tracing_futures::Instrument;
@@ -91,9 +92,13 @@ async fn main() -> anyhow::Result<()> {
9192
description = built_info::PKG_DESCRIPTION
9293
);
9394

95+
// Watches for the SIGTERM signal and sends a signal to all receivers, which gracefully
96+
// shuts down all concurrent tasks below (EoS checker, controller).
97+
let sigterm_watcher = SignalWatcher::sigterm()?;
98+
9499
let eos_checker =
95100
EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)?
96-
.run()
101+
.run(sigterm_watcher.handle())
97102
.map(anyhow::Ok);
98103

99104
let product_config = product_config.load(&[
@@ -152,7 +157,6 @@ async fn main() -> anyhow::Result<()> {
152157
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
153158
watcher::Config::default(),
154159
)
155-
.shutdown_on_signal()
156160
.watches(
157161
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
158162
watcher::Config::default(),
@@ -164,6 +168,7 @@ async fn main() -> anyhow::Result<()> {
164168
.map(|hdfs| reflector::ObjectRef::from_obj(&*hdfs))
165169
},
166170
)
171+
.graceful_shutdown_on(sigterm_watcher.handle())
167172
.run(
168173
hdfs_controller::reconcile_hdfs,
169174
hdfs_controller::error_policy,

0 commit comments

Comments
 (0)