diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4db55..5155f47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Gracefully shutdown all concurrent tasks by forwarding the SIGTERM signal ([#366]). - OLM deployer doesn't add owner references to cluster scoped objects anymore ([#360]). Owner references ensure that objects are garbage collected by OpenShift upon operator removal but they cause problems when the operator is updated. This means that cluster wide objects are not removed anymore when the operator is uninstalled. @@ -22,6 +23,7 @@ All notable changes to this project will be documented in this file. [#363]: https://github.com/stackabletech/listener-operator/pull/363 [#364]: https://github.com/stackabletech/listener-operator/pull/364 [#365]: https://github.com/stackabletech/listener-operator/pull/365 +[#366]: https://github.com/stackabletech/listener-operator/pull/366 ## [25.11.0] - 2025-11-07 diff --git a/Cargo.lock b/Cargo.lock index d4148d5..110da17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,9 +275,9 @@ checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" @@ -896,9 +896,9 @@ dependencies = [ [[package]] name = "git2" -version = "0.20.2" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" +checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b" dependencies = [ "bitflags", "libc", @@ -1375,7 +1375,7 @@ dependencies = [ [[package]] name = "k8s-version" version = "0.1.3" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "darling 0.23.0", "regex", @@ -1500,9 +1500,9 @@ checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" [[package]] name = "libgit2-sys" -version = "0.18.2+1.9.1" +version = "0.18.3+1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222" +checksum = "c9b3acc4b91781bb0b3386669d325163746af5f6e4f73e6d2d630e09a35f3487" dependencies = [ "cc", "libc", @@ -2582,8 +2582,8 @@ dependencies = [ [[package]] name = "stackable-operator" -version = "0.104.0" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +version = "0.105.0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "chrono", "clap", @@ -2621,7 +2621,7 @@ dependencies = [ [[package]] name = "stackable-operator-derive" version = "0.3.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "darling 0.23.0", "proc-macro2", @@ -2632,7 +2632,7 @@ dependencies = [ [[package]] name = "stackable-shared" version = "0.0.3" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "chrono", "k8s-openapi", @@ -2649,7 +2649,7 @@ dependencies = [ [[package]] name = "stackable-telemetry" version = "0.6.1" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "axum", "clap", @@ -2673,7 +2673,7 @@ dependencies = [ [[package]] name = "stackable-versioned" version = "0.8.3" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "schemars", "serde", @@ -2686,7 +2686,7 @@ dependencies = [ [[package]] name = "stackable-versioned-macros" version = "0.8.3" -source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#99ceb14e2466a8928b0075ad21c4aafeb54dcfe0" +source = "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa" dependencies = [ "convert_case", "darling 0.23.0", diff --git a/Cargo.nix b/Cargo.nix index 43e8bf8..a49689d 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -905,9 +905,9 @@ rec { }; "bytes" = rec { crateName = "bytes"; - version = "1.10.1"; - edition = "2018"; - sha256 = "0smd4wi2yrhp5pmq571yiaqx84bjqlm1ixqhnvfwzzc6pqkn26yp"; + version = "1.11.1"; + edition = "2021"; + sha256 = "0czwlhbq8z29wq0ia87yass2mzy1y0jcasjb8ghriiybnwrqfx0y"; authors = [ "Carl Lerche " "Sean McArthur " @@ -2742,9 +2742,9 @@ rec { }; "git2" = rec { crateName = "git2"; - version = "0.20.2"; + version = "0.20.4"; edition = "2018"; - sha256 = "0451zzmvblvlrj6y6pgdsxrqh42hi789n3k9lp0hslmi6fhhgsrd"; + sha256 = "0azykjpk3j6s354z23jkyq3r3pbmlw9ha1zsxkw5cnnpi1h2b23v"; authors = [ "Josh Triplett " "Alex Crichton " @@ -4301,8 +4301,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; libName = "k8s_version"; authors = [ @@ -4941,10 +4941,10 @@ rec { }; "libgit2-sys" = rec { crateName = "libgit2-sys"; - version = "0.18.2+1.9.1"; - edition = "2018"; + version = "0.18.3+1.9.2"; + edition = "2021"; links = "git2"; - sha256 = "08n223x2pkf4gj6yrjmh3z6q236qj6nifwww78xcblrbvw1zwhhw"; + sha256 = "11rlbyihj3k35mnkxxz4yvsnlx33a4r9srl66c5vp08pp72arcy9"; libName = "libgit2_sys"; libPath = "lib.rs"; authors = [ @@ -8549,13 +8549,13 @@ rec { }; "stackable-operator" = rec { crateName = "stackable-operator"; - version = "0.104.0"; + version = "0.105.0"; edition = "2024"; workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; libName = "stackable_operator"; authors = [ @@ -8723,8 +8723,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; procMacro = true; libName = "stackable_operator_derive"; @@ -8758,8 +8758,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; libName = "stackable_shared"; authors = [ @@ -8840,8 +8840,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; libName = "stackable_telemetry"; authors = [ @@ -8950,8 +8950,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; libName = "stackable_versioned"; authors = [ @@ -8994,8 +8994,8 @@ rec { workspace_member = null; src = pkgs.fetchgit { url = "https://github.com/stackabletech/operator-rs.git"; - rev = "99ceb14e2466a8928b0075ad21c4aafeb54dcfe0"; - sha256 = "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh"; + rev = "7bfcac5f6515c8b4c8cf8def2edfde5ed8621aaa"; + sha256 = "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd"; }; procMacro = true; libName = "stackable_versioned_macros"; diff --git a/Cargo.toml b/Cargo.toml index e057e9d..c39b567 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,10 @@ edition = "2021" repository = "https://github.com/stackabletech/listener-operator" [workspace.dependencies] -stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.104.0", features = ["telemetry", "versioned"] } +stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.105.0", features = [ + "telemetry", + "versioned", +] } anyhow = "1.0" built = { version = "0.8", features = ["chrono", "git2"] } diff --git a/crate-hashes.json b/crate-hashes.json index 3934aee..c7bba39 100644 --- a/crate-hashes.json +++ b/crate-hashes.json @@ -4,12 +4,12 @@ "git+https://github.com/stackabletech/kube-rs?branch=2.0.1-fix-schema-hoisting#kube-derive@2.0.1": "1a7bcl0w1jg71jc4iml0vjp8dpzy71mhxl012grxcy2xp5i6xvgf", "git+https://github.com/stackabletech/kube-rs?branch=2.0.1-fix-schema-hoisting#kube-runtime@2.0.1": "1a7bcl0w1jg71jc4iml0vjp8dpzy71mhxl012grxcy2xp5i6xvgf", "git+https://github.com/stackabletech/kube-rs?branch=2.0.1-fix-schema-hoisting#kube@2.0.1": "1a7bcl0w1jg71jc4iml0vjp8dpzy71mhxl012grxcy2xp5i6xvgf", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#k8s-version@0.1.3": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-operator-derive@0.3.1": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-operator@0.104.0": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-shared@0.0.3": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-telemetry@0.6.1": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-versioned-macros@0.8.3": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", - "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.104.0#stackable-versioned@0.8.3": "07cdivnyvrfrznqqm0hqsbvmbng00scv22p39a3wdgfanamjpjsh", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#k8s-version@0.1.3": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-operator-derive@0.3.1": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-operator@0.105.0": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-shared@0.0.3": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-telemetry@0.6.1": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-versioned-macros@0.8.3": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", + "git+https://github.com/stackabletech/operator-rs.git?tag=stackable-operator-0.105.0#stackable-versioned@0.8.3": "02z7c2kjhcwg153j74n52wwcr5x0z70hc21hlsrxyclmc8ps1lmd", "git+https://github.com/stackabletech/product-config.git?tag=0.8.0#product-config@0.8.0": "1dz70kapm2wdqcr7ndyjji0lhsl98bsq95gnb2lw487wf6yr7987" } \ No newline at end of file diff --git a/rust/operator-binary/src/listener_controller.rs b/rust/operator-binary/src/listener_controller.rs index 9d1a4f6..67d20d8 100644 --- a/rust/operator-binary/src/listener_controller.rs +++ b/rust/operator-binary/src/listener_controller.rs @@ -1,5 +1,6 @@ use std::{ collections::{BTreeMap, BTreeSet}, + future::Future, sync::Arc, }; @@ -48,7 +49,10 @@ const OPERATOR_NAME: &str = "listeners.stackable.tech"; const CONTROLLER_NAME: &str = "listener"; pub const FULL_CONTROLLER_NAME: &str = concatcp!(CONTROLLER_NAME, '.', OPERATOR_NAME); -pub async fn run(client: stackable_operator::client::Client) { +pub async fn run(client: stackable_operator::client::Client, shutdown_signal: F) +where + F: Future + Send + Sync + 'static, +{ let controller = controller::Controller::new( client.get_all_api::>(), watcher::Config::default(), @@ -119,7 +123,7 @@ pub async fn run(client: stackable_operator::client::Client) { }) }, ) - .shutdown_on_signal() + .graceful_shutdown_on(shutdown_signal) .run( reconcile, error_policy, diff --git a/rust/operator-binary/src/main.rs b/rust/operator-binary/src/main.rs index e260020..fe16503 100644 --- a/rust/operator-binary/src/main.rs +++ b/rust/operator-binary/src/main.rs @@ -23,8 +23,8 @@ use stackable_operator::{ eos::EndOfSupportChecker, shared::yaml::SerializeOptions, telemetry::Tracing, + utils::signal::SignalWatcher, }; -use tokio::signal::unix::{SignalKind, signal}; use tokio_stream::wrappers::UnixListenerStream; use tonic::transport::Server; use utils::unix_stream::{TonicUnixStream, uds_bind_private}; @@ -116,9 +116,13 @@ async fn main() -> anyhow::Result<()> { description = built_info::PKG_DESCRIPTION ); + // Watches for the SIGTERM signal and sends a signal to all receivers, which gracefully + // shuts down all concurrent tasks below (EoS checker, controller). + let sigterm_watcher = SignalWatcher::sigterm()?; + let eos_checker = EndOfSupportChecker::new(built_info::BUILT_TIME_UTC, maintenance.end_of_support)? - .run() + .run(sigterm_watcher.handle()) .map(anyhow::Ok); let client = stackable_operator::client::initialize_operator( @@ -134,9 +138,9 @@ async fn main() -> anyhow::Result<()> { let _ = std::fs::remove_file(&csi_endpoint); } - let mut sigterm = signal(SignalKind::terminate())?; let csi_listener = UnixListenerStream::new(uds_bind_private(csi_endpoint)?).map_ok(TonicUnixStream); + let csi_server = Server::builder() .add_service( tonic_reflection::server::Builder::configure() @@ -152,9 +156,10 @@ async fn main() -> anyhow::Result<()> { .add_service(ControllerServer::new(ListenerOperatorController { client: client.clone(), })) - .serve_with_incoming_shutdown(csi_listener, sigterm.recv().map(|_| ())) + .serve_with_incoming_shutdown(csi_listener, sigterm_watcher.handle()) .map_err(|err| anyhow!(err).context("failed to run csi server")); - let controller = listener_controller::run(client).map(anyhow::Ok); + let controller = + listener_controller::run(client, sigterm_watcher.handle()).map(anyhow::Ok); futures::try_join!(csi_server, controller, eos_checker)?; } @@ -165,7 +170,7 @@ async fn main() -> anyhow::Result<()> { client: client.clone(), node_name: node_name.to_owned(), })) - .serve_with_incoming_shutdown(csi_listener, sigterm.recv().map(|_| ())) + .serve_with_incoming_shutdown(csi_listener, sigterm_watcher.handle()) .map_err(|err| anyhow!(err).context("failed to run csi server")); futures::try_join!(csi_server, eos_checker)?;