File tree Expand file tree Collapse file tree
crates/stackable-webhook/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -158,7 +158,10 @@ impl WebhookServer {
158158
159159 /// Runs the Webhook server and sets up signal handlers for shutting down.
160160 ///
161- /// This does not implement graceful shutdown of the underlying server.
161+ /// This does not implement graceful shutdown of the underlying server. Additionally, the server
162+ /// is never started in cases where no [`Webhook`] is registered. Callers of this function need
163+ /// to ensure to choose the correct joining mechanism for their use-case to for example avoid
164+ /// unexpected shutdowns of the whole Kubernetes controller.
162165 pub async fn run ( self ) -> Result < ( ) > {
163166 let future_server = self . run_server ( ) ;
164167 let future_signal = async {
@@ -207,6 +210,14 @@ impl WebhookServer {
207210 tls_server,
208211 mut cert_rx,
209212 } = self ;
213+
214+ // If no webhooks are registered exit immediately without spanning the TLS server and the
215+ // certificate rotation loop.
216+ if webhooks. is_empty ( ) {
217+ tracing:: debug!( "no registered webhooks, returning without starting TLS server" ) ;
218+ return Ok ( ( ) ) ;
219+ }
220+
210221 let tls_server = tls_server
211222 . run ( )
212223 . map_err ( |err| WebhookServerError :: RunTlsServer { source : err } ) ;
You can’t perform that action at this time.
0 commit comments