Skip to content

Commit fe3eb87

Browse files
authored
feat: Add graceful shutdown (#934)
* feat: Add graceful shutdown * chore: Update CRD documentation * chore: Bump bytes crate to 1.11.1 This fixes RUSTSEC-2026-0007. * chore: Add changelog entry
1 parent 3355896 commit fe3eb87

7 files changed

Lines changed: 49 additions & 42 deletions

File tree

CHANGELOG.md

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

1515
### Changed
1616

17+
- Gracefully shutdown all concurrent tasks by forwarding the SIGTERM signal ([#934]).
1718
- Refactor: move server configuration properties from the command line to configuration files. ([#911]).
1819
- Add support for ZooKeeper to KRaft migration ([#923]), ([#933]).
1920
- Bump testing-tools to `0.3.0-stackable0.0.0-dev` ([#925]).
@@ -35,6 +36,7 @@ All notable changes to this project will be documented in this file.
3536
[#930]: https://github.com/stackabletech/kafka-operator/pull/930
3637
[#932]: https://github.com/stackabletech/kafka-operator/pull/932
3738
[#933]: https://github.com/stackabletech/kafka-operator/pull/933
39+
[#934]: https://github.com/stackabletech/kafka-operator/pull/934
3840

3941
## [25.11.0] - 2025-11-07
4042

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
@@ -11,7 +11,7 @@ repository = "https://github.com/stackabletech/kafka-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.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ spec:
346346
default: {}
347347
description: |-
348348
In the `podOverrides` property you can define a
349-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
349+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
350350
to override any property that can be set on a Kubernetes Pod.
351351
Read the
352352
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)
@@ -702,7 +702,7 @@ spec:
702702
default: {}
703703
description: |-
704704
In the `podOverrides` property you can define a
705-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
705+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
706706
to override any property that can be set on a Kubernetes Pod.
707707
Read the
708708
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)
@@ -1228,7 +1228,7 @@ spec:
12281228
default: {}
12291229
description: |-
12301230
In the `podOverrides` property you can define a
1231-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
1231+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
12321232
to override any property that can be set on a Kubernetes Pod.
12331233
Read the
12341234
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)
@@ -1576,7 +1576,7 @@ spec:
15761576
default: {}
15771577
description: |-
15781578
In the `podOverrides` property you can define a
1579-
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.27/#podtemplatespec-v1-core)
1579+
[PodTemplateSpec](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#podtemplatespec-v1-core)
15801580
to override any property that can be set on a Kubernetes Pod.
15811581
Read the
15821582
[Pod overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#pod-overrides)

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

3536
use crate::{
@@ -99,9 +100,13 @@ async fn main() -> anyhow::Result<()> {
99100
description = built_info::PKG_DESCRIPTION
100101
);
101102

103+
// Watches for the SIGTERM signal and sends a signal to all receivers, which gracefully
104+
// shuts down all concurrent tasks below (EoS checker, controller).
105+
let sigterm_watcher = SignalWatcher::sigterm()?;
106+
102107
let eos_checker =
103108
EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)?
104-
.run()
109+
.run(sigterm_watcher.handle())
105110
.map(anyhow::Ok);
106111

107112
let product_config = product_config.load(&[
@@ -150,7 +155,6 @@ async fn main() -> anyhow::Result<()> {
150155
watch_namespace.get_api::<RoleBinding>(&client),
151156
watcher::Config::default(),
152157
)
153-
.shutdown_on_signal()
154158
.watches(
155159
watch_namespace.get_api::<DeserializeGuard<ConfigMap>>(&client),
156160
watcher::Config::default(),
@@ -162,6 +166,7 @@ async fn main() -> anyhow::Result<()> {
162166
.map(|kafka| ObjectRef::from_obj(&*kafka))
163167
},
164168
)
169+
.graceful_shutdown_on(sigterm_watcher.handle())
165170
.run(
166171
kafka_controller::reconcile_kafka,
167172
kafka_controller::error_policy,

0 commit comments

Comments
 (0)