@@ -45,6 +45,8 @@ pub struct ProbeConfig {
4545 /// Runtime watchdog configuration.
4646 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
4747 watchdog : Option < WatchdogConfig > ,
48+ #[ serde( default ) ]
49+ start_in_maintenance : bool ,
4850}
4951
5052impl Default for ProbeConfig {
@@ -55,6 +57,7 @@ impl Default for ProbeConfig {
5557 maintenance_on_path : Self :: default_maintenance_on_path ( ) ,
5658 maintenance_off_path : Self :: default_maintenance_off_path ( ) ,
5759 watchdog : Some ( WatchdogConfig :: default ( ) ) ,
60+ start_in_maintenance : false ,
5861 }
5962 }
6063}
@@ -102,7 +105,7 @@ impl ProbeConfig {
102105 {
103106 // TODO: add toggle for probes, and possibly for maintenance mode.
104107 let _span = debug_span ! ( "build_probes" ) . entered ( ) ;
105- let state = ProbeState :: new ( self . watchdog . as_ref ( ) ) ;
108+ let state = ProbeState :: new ( self . start_in_maintenance , self . watchdog . as_ref ( ) ) ;
106109 Router :: new ( )
107110 . route ( & self . readiness_path , routing:: get ( readiness_probe) )
108111 . route ( & self . liveness_path , routing:: get ( liveness_probe) )
@@ -148,9 +151,9 @@ impl Default for ProbeState {
148151impl ProbeState {
149152 /// Create new [`ProbeState`] with optional [`WatchdogConfig`].
150153 #[ must_use]
151- pub fn new ( watchdog : Option < & WatchdogConfig > ) -> Self {
154+ pub fn new ( in_maint : bool , watchdog : Option < & WatchdogConfig > ) -> Self {
152155 Self ( Arc :: new ( ProbeStateInner {
153- in_maintenance : AtomicBool :: new ( true ) ,
156+ in_maintenance : AtomicBool :: new ( in_maint ) ,
154157 watchdog : watchdog. map ( |wc| {
155158 let mut watchdog: Watchdog = wc. clone ( ) . into ( ) ;
156159 watchdog. start ( ) ;
0 commit comments