Skip to content

Commit

Permalink
[release-0.5] [kueue] Check certificates readiness before the webhook…
Browse files Browse the repository at this point in the history
… server. (#1713)

* Check certificates readiness before the webhook server.

* Don't keep the caller busy.

---------

Co-authored-by: Traian Schiau <[email protected]>
  • Loading branch information
k8s-infra-cherrypick-robot and trasc authored Feb 9, 2024
1 parent a60e5f7 commit 9f9069f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/kueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func main() {

serverVersionFetcher := setupServerVersionFetcher(mgr, kubeConfig)

setupProbeEndpoints(mgr)
setupProbeEndpoints(mgr, certsReady)
// Cert won't be ready until manager starts, so start a goroutine here which
// will block until the cert is ready before setting up the controllers.
// Controllers who register after manager starts will start directly.
Expand Down Expand Up @@ -302,7 +302,7 @@ func setupControllers(mgr ctrl.Manager, cCache *cache.Cache, queues *queue.Manag
}

// setupProbeEndpoints registers the health endpoints
func setupProbeEndpoints(mgr ctrl.Manager) {
func setupProbeEndpoints(mgr ctrl.Manager, certsReady <-chan struct{}) {
defer setupLog.Info("Probe endpoints are configured on healthz and readyz")

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand All @@ -318,7 +318,12 @@ func setupProbeEndpoints(mgr ctrl.Manager) {
// the function, otherwise a not fully-initialized webhook server (without
// ready certs) fails the start of the manager.
if err := mgr.AddReadyzCheck("readyz", func(req *http.Request) error {
return mgr.GetWebhookServer().StartedChecker()(req)
select {
case <-certsReady:
return mgr.GetWebhookServer().StartedChecker()(req)
default:
return errors.New("certificates are not ready")
}
}); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
Expand Down

0 comments on commit 9f9069f

Please sign in to comment.