22// This will need changes in our and upstream error types.
33#![ allow( clippy:: result_large_err) ]
44
5- use std:: { os:: unix:: prelude:: FileTypeExt , path:: PathBuf } ;
5+ use std:: { future :: Future , os:: unix:: prelude:: FileTypeExt , path:: PathBuf } ;
66
77use anyhow:: { Context , Ok , anyhow} ;
88use clap:: Parser ;
@@ -24,7 +24,6 @@ use stackable_operator::{
2424 telemetry:: Tracing ,
2525 utils:: signal:: SignalWatcher ,
2626} ;
27- use tokio:: sync:: oneshot;
2827use tokio_stream:: wrappers:: UnixListenerStream ;
2928use tonic:: transport:: Server ;
3029use utils:: { TonicUnixStream , uds_bind_private} ;
@@ -209,6 +208,12 @@ async fn main() -> anyhow::Result<()> {
209208 )
210209 . await ?;
211210
211+ // Here, we multiply the initial reconcile signal received by the oneshot receiver
212+ // to be able to pass it to both the default custom resource deployer and to delay
213+ // the startup of the controller.
214+ let initial_reconcile_signal =
215+ SignalWatcher :: new ( initial_reconcile_rx. map ( |_| ( ) ) ) ;
216+
212217 let webhook_server = webhook_server
213218 . run ( sigterm_watcher. handle ( ) )
214219 . map_err ( |err| anyhow ! ( err) . context ( "failed to run webhook server" ) ) ;
@@ -217,7 +222,7 @@ async fn main() -> anyhow::Result<()> {
217222 . unwrap_or ( operator_environment. operator_namespace . clone ( ) ) ;
218223
219224 let default_secretclass = create_default_secretclass (
220- initial_reconcile_rx ,
225+ initial_reconcile_signal . handle ( ) ,
221226 ca_secret_namespace,
222227 client. clone ( ) ,
223228 )
@@ -232,8 +237,13 @@ async fn main() -> anyhow::Result<()> {
232237 )
233238 . map ( anyhow:: Ok ) ;
234239
240+ let delayed_truststore_controller = async {
241+ let _ = initial_reconcile_signal. handle ( ) . await ;
242+ truststore_controller. await
243+ } ;
244+
235245 try_join ! (
236- truststore_controller ,
246+ delayed_truststore_controller ,
237247 default_secretclass,
238248 webhook_server,
239249 eos_checker,
@@ -247,11 +257,11 @@ async fn main() -> anyhow::Result<()> {
247257}
248258
249259async fn create_default_secretclass (
250- initial_reconcile_rx : oneshot :: Receiver < ( ) > ,
260+ initial_reconcile_signal : impl Future < Output = ( ) > ,
251261 ca_secret_namespace : String ,
252262 client : Client ,
253263) -> anyhow:: Result < ( ) > {
254- initial_reconcile_rx . await ? ;
264+ initial_reconcile_signal . await ;
255265
256266 tracing:: info!( "applying default secretclass" ) ;
257267
0 commit comments