@@ -38,6 +38,7 @@ use stackable_operator::{
3838 logging:: controller:: report_controller_reconciled,
3939 shared:: yaml:: SerializeOptions ,
4040 telemetry:: Tracing ,
41+ utils:: signal:: SignalWatcher ,
4142} ;
4243
4344use 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 ( & [
@@ -129,7 +134,6 @@ async fn main() -> anyhow::Result<()> {
129134 watch_namespace. get_api :: < ConfigMap > ( & client) ,
130135 watcher:: Config :: default ( ) ,
131136 )
132- . shutdown_on_signal ( )
133137 . watches (
134138 watch_namespace. get_api :: < DeserializeGuard < ConfigMap > > ( & client) ,
135139 watcher:: Config :: default ( ) ,
@@ -141,6 +145,7 @@ async fn main() -> anyhow::Result<()> {
141145 . map ( |hive| ObjectRef :: from_obj ( & * hive) )
142146 } ,
143147 )
148+ . graceful_shutdown_on ( sigterm_watcher. handle ( ) )
144149 . run (
145150 controller:: reconcile_hive,
146151 controller:: error_policy,
0 commit comments