@@ -176,6 +176,8 @@ func AddRotator(mgr manager.Manager, cr *CertRotator) error {
176
176
needLeaderElection : cr .RequireLeaderElection ,
177
177
refreshCertIfNeededDelegate : cr .refreshCertIfNeeded ,
178
178
fieldOwner : cr .FieldOwner ,
179
+ certsMounted : cr .certsMounted ,
180
+ enableReadinessCheck : cr .EnableReadinessCheck ,
179
181
}
180
182
if err := addController (mgr , reconciler , cr .controllerName ); err != nil {
181
183
return err
@@ -251,6 +253,10 @@ type CertRotator struct {
251
253
CertName string
252
254
KeyName string
253
255
256
+ // EnableReadinessCheck if true, reconcilation loop will wait for controller-runtime's
257
+ // runnable to finish execution.
258
+ EnableReadinessCheck bool
259
+
254
260
certsMounted chan struct {}
255
261
certsNotMounted chan struct {}
256
262
wasCAInjected * atomic.Bool
@@ -743,6 +749,8 @@ type ReconcileWH struct {
743
749
needLeaderElection bool
744
750
refreshCertIfNeededDelegate func () (bool , error )
745
751
fieldOwner string
752
+ certsMounted chan struct {}
753
+ enableReadinessCheck bool
746
754
}
747
755
748
756
// Reconcile reads that state of the cluster for a validatingwebhookconfiguration
@@ -752,6 +760,10 @@ func (r *ReconcileWH) Reconcile(ctx context.Context, request reconcile.Request)
752
760
return reconcile.Result {}, nil
753
761
}
754
762
763
+ if r .enableReadinessCheck {
764
+ <- r .certsMounted
765
+ }
766
+
755
767
if ! r .cache .WaitForCacheSync (ctx ) {
756
768
return reconcile.Result {}, errors .New ("cache not ready" )
757
769
}
0 commit comments