Skip to content

Commit 90ef442

Browse files
authored
feat: Add graceful shutdown (#788)
* feat: Add graceful shutdown * chore: Add changelog entry
1 parent aaa46bc commit 90ef442

File tree

6 files changed

+40
-33
lines changed

6 files changed

+40
-33
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ All notable changes to this project will be documented in this file.
1515

1616
### Changed
1717

18+
- Gracefully shutdown all concurrent tasks by forwarding the SIGTERM signal ([#788]).
1819
- Bump testing-tools to `0.3.0-stackable0.0.0-dev` ([#780]).
1920

2021
[#780]: https://github.com/stackabletech/druid-operator/pull/780
22+
[#788]: https://github.com/stackabletech/druid-operator/pull/788
2123

2224
## [25.11.0] - 2025-11-07
2325

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/druid-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.104.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
@@ -28,6 +28,7 @@ use stackable_operator::{
2828
logging::controller::report_controller_reconciled,
2929
shared::yaml::SerializeOptions,
3030
telemetry::Tracing,
31+
utils::signal::SignalWatcher,
3132
};
3233

3334
use crate::crd::{DruidCluster, DruidClusterVersion, OPERATOR_NAME, v1alpha1};
@@ -85,9 +86,13 @@ async fn main() -> anyhow::Result<()> {
8586
description = built_info::PKG_DESCRIPTION
8687
);
8788

89+
// Watches for the SIGTERM signal and sends a signal to all receivers, which gracefully
90+
// shuts down all concurrent tasks below (EoS checker, controller).
91+
let sigterm_watcher = SignalWatcher::sigterm()?;
92+
8893
let eos_checker =
8994
EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)?
90-
.run()
95+
.run(sigterm_watcher.handle())
9196
.map(anyhow::Ok);
9297

9398
let product_config = product_config.load(&[
@@ -126,7 +131,6 @@ async fn main() -> anyhow::Result<()> {
126131
watch_namespace.get_api::<ConfigMap>(&client),
127132
watcher::Config::default(),
128133
)
129-
.shutdown_on_signal()
130134
.watches(
131135
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
132136
watcher::Config::default(),
@@ -138,6 +142,7 @@ async fn main() -> anyhow::Result<()> {
138142
.map(|druid| ObjectRef::from_obj(&*druid))
139143
},
140144
)
145+
.graceful_shutdown_on(sigterm_watcher.handle())
141146
.run(
142147
druid_controller::reconcile_druid,
143148
druid_controller::error_policy,

0 commit comments

Comments
 (0)