Skip to content

Commit 078b9b8

Browse files
authored
feat: Add graceful shutdown (#110)
* feat: Add graceful shutdown * chore: Update CRD documentation * chore: Bump bytes crate to 1.11.1 Fixes RUSTSEC-2026-0007. * chore: Add changelog entry
1 parent f5026f5 commit 078b9b8

7 files changed

Lines changed: 52 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file.
2929

3030
### Changed
3131

32+
- Gracefully shutdown all concurrent tasks by forwarding the SIGTERM signal ([#110]).
3233
- Bump testing-tools to `0.3.0-stackable0.0.0-dev` ([#91]).
3334

3435
### Fixed
@@ -45,6 +46,7 @@ All notable changes to this project will be documented in this file.
4546
[#100]: https://github.com/stackabletech/opensearch-operator/pull/100
4647
[#107]: https://github.com/stackabletech/opensearch-operator/pull/107
4748
[#108]: https://github.com/stackabletech/opensearch-operator/pull/108
49+
[#110]: https://github.com/stackabletech/opensearch-operator/pull/110
4850

4951
## [25.11.0] - 2025-11-07
5052

Cargo.lock

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

Cargo.nix

Lines changed: 18 additions & 18 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.

deploy/helm/opensearch-operator/crds/crds.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ spec:
512512
default: {}
513513
description: |-
514514
In the `podOverrides` property you can define a
515-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
515+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
516516
to override any property that can be set on a Kubernetes Pod.
517517
Read the
518518
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)
@@ -878,7 +878,7 @@ spec:
878878
default: {}
879879
description: |-
880880
In the `podOverrides` property you can define a
881-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
881+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
882882
to override any property that can be set on a Kubernetes Pod.
883883
Read the
884884
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)

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)