Skip to content

Commit cced37c

Browse files
committed
feat: Add graceful shutdown
1 parent a7f8c04 commit cced37c

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/nifi-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
@@ -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::{
@@ -88,9 +89,13 @@ async fn main() -> anyhow::Result<()> {
8889
description = built_info::PKG_DESCRIPTION
8990
);
9091

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

96101
let product_config = product_config.load(&[
@@ -133,7 +138,6 @@ async fn main() -> anyhow::Result<()> {
133138
watch_namespace.get_api::<ConfigMap>(&client),
134139
watcher::Config::default(),
135140
)
136-
.shutdown_on_signal()
137141
.watches(
138142
client
139143
.get_api::<DeserializeGuard<auth_core::v1alpha1::AuthenticationClass>>(&()),
@@ -156,6 +160,7 @@ async fn main() -> anyhow::Result<()> {
156160
.map(|nifi| ObjectRef::from_obj(&*nifi))
157161
},
158162
)
163+
.graceful_shutdown_on(sigterm_watcher.handle())
159164
.run(
160165
controller::reconcile_nifi,
161166
controller::error_policy,

0 commit comments

Comments
 (0)