@@ -91,17 +91,22 @@ pub struct ConversionWebhookServer {
9191 options : ConversionWebhookOptions ,
9292 router : Router ,
9393 client : Client ,
94+ maintain_crds : bool ,
9495}
9596
9697impl ConversionWebhookServer {
9798 /// Creates a new conversion webhook server, which expects POST requests being made to the
9899 /// `/convert/{crd name}` endpoint.
99100 ///
100- /// You need to provide two things for every CRD passed in via the `crds_and_handlers` argument:
101+ /// You need to provide a few things for every CRD passed in via the `crds_and_handlers` argument:
101102 ///
102103 /// 1. The CRD
103104 /// 2. A conversion function to convert between CRD versions. Typically you would use the
104- /// the auto-generated `try_convert` function on CRD spec definition structs for this.
105+ /// the auto-generated `try_convert` function on CRD spec definition structs for this.
106+ /// 3. A [`kube::Client`] used to create/update the CRDs.
107+ /// 4. If we should maintain the CRDs. Use `stackable_operator::cli::ProductOperatorRun::disable_crd_maintenance`
108+ /// for this.
109+ // # Because of https://github.com/rust-lang/cargo/issues/3475 we can not use a real link here
105110 ///
106111 /// The [`ConversionWebhookServer`] takes care of reconciling the CRDs into the Kubernetes
107112 /// cluster and takes care of adding itself as conversion webhook. This includes TLS
@@ -165,6 +170,7 @@ impl ConversionWebhookServer {
165170 crds_and_handlers : impl IntoIterator < Item = ( CustomResourceDefinition , H ) > ,
166171 options : ConversionWebhookOptions ,
167172 client : Client ,
173+ maintain_crds : bool ,
168174 ) -> Result < Self , ConversionWebhookError >
169175 where
170176 H : WebhookHandler < ConversionReview , ConversionReview > + Clone + Send + Sync + ' static ,
@@ -190,6 +196,7 @@ impl ConversionWebhookServer {
190196 router,
191197 client,
192198 crds,
199+ maintain_crds,
193200 } )
194201 }
195202
@@ -201,6 +208,7 @@ impl ConversionWebhookServer {
201208 router,
202209 client,
203210 crds,
211+ maintain_crds,
204212 } = self ;
205213
206214 let ConversionWebhookOptions {
@@ -233,28 +241,34 @@ impl ConversionWebhookServer {
233241 . recv ( )
234242 . await
235243 . context ( ReceiveCertificateFromChannelSnafu ) ?;
236- Self :: reconcile_crds (
237- & client,
238- field_manager,
239- & crds,
240- operator_namespace,
241- operator_service_name,
242- current_cert,
243- )
244- . await
245- . context ( ReconcileCrdsSnafu ) ?;
246-
247- try_join ! (
248- Self :: run_webhook_server( server) ,
249- Self :: run_crd_reconciliation_loop(
250- cert_rx,
244+ if maintain_crds {
245+ Self :: reconcile_crds (
251246 & client,
252247 field_manager,
253248 & crds,
254249 operator_namespace,
255250 operator_service_name,
256- ) ,
257- ) ?;
251+ current_cert,
252+ )
253+ . await
254+ . context ( ReconcileCrdsSnafu ) ?;
255+ }
256+
257+ if maintain_crds {
258+ try_join ! (
259+ Self :: run_webhook_server( server) ,
260+ Self :: run_crd_reconciliation_loop(
261+ cert_rx,
262+ & client,
263+ field_manager,
264+ & crds,
265+ operator_namespace,
266+ operator_service_name,
267+ ) ,
268+ ) ?;
269+ } else {
270+ Self :: run_webhook_server ( server) . await ?;
271+ } ;
258272
259273 Ok ( ( ) )
260274 }
0 commit comments