Skip to content

Commit

Permalink
Fix Kueue startup by waiting for webhooks server using probes (#1676)
Browse files Browse the repository at this point in the history
* Wait for webhooks server using probes

* Delete KueueReadyForTesting

* revert the setting of healthz

* Add a comment about the readyz probe
  • Loading branch information
mimowo authored Feb 1, 2024
1 parent af8bb54 commit a8c11f3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 32 deletions.
12 changes: 0 additions & 12 deletions cmd/experimental/podtaintstolerations/test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
kueuetest "sigs.k8s.io/kueue/pkg/util/testing"
"sigs.k8s.io/kueue/test/util"
)

var (
Expand Down Expand Up @@ -67,17 +65,7 @@ func CreateClientUsingCluster() client.Client {
return client
}

func KueueReadyForTesting(client client.Client) {
// To verify that webhooks are ready, let's create a simple resourceflavor
resourceKueue := kueuetest.MakeResourceFlavor("default").Obj()
gomega.Eventually(func() error {
return client.Create(context.Background(), resourceKueue)
}, Timeout, Interval).Should(gomega.Succeed())
util.ExpectResourceFlavorToBeDeleted(ctx, k8sClient, resourceKueue, true)
}

var _ = ginkgo.BeforeSuite(func() {
k8sClient = CreateClientUsingCluster()
ctx = context.Background()
KueueReadyForTesting(k8sClient)
})
13 changes: 12 additions & 1 deletion cmd/kueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"flag"
"net/http"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand Down Expand Up @@ -278,7 +279,17 @@ func setupProbeEndpoints(mgr ctrl.Manager) {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
}
if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {

// Wait for the webhook server to be listening before advertising the
// Kueue replica as ready. This allows users to wait with sending the first
// requests, requiring webhooks, until the Kueue deployment is available, so
// that the early requests are not rejected during the Kueue's startup.
// We wrap the call to GetWebhookServer in a closure to delay calling
// 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)
}); err != nil {
setupLog.Error(err, "unable to set up ready check")
os.Exit(1)
}
Expand Down
1 change: 1 addition & 0 deletions hack/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ function cluster_kueue_deploy {
else
kubectl apply --server-side -k test/e2e/config
fi
kubectl wait --for=condition=available --timeout=3m deployment/kueue-controller-manager -n kueue-system
}

7 changes: 0 additions & 7 deletions test/e2e/multikueue/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,4 @@ var _ = ginkgo.BeforeSuite(func() {
k8sWorker2Client = util.CreateClientUsingCluster("kind-" + worker2ClusterName)

ctx = context.Background()

//wait for the managers to start
// failing a this point might indicate a manifestation of
// https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files
util.KueueReadyForTesting(ctx, k8sManagerClient)
util.KueueReadyForTesting(ctx, k8sWorker1Client)
util.KueueReadyForTesting(ctx, k8sWorker2Client)
})
1 change: 0 additions & 1 deletion test/e2e/singlecluster/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ var _ = ginkgo.BeforeSuite(func() {
visibilityClient = util.CreateVisibilityClient("")
impersonatedVisibilityClient = util.CreateVisibilityClient("system:serviceaccount:kueue-system:default")
ctx = context.Background()
util.KueueReadyForTesting(ctx, k8sClient)
})
11 changes: 0 additions & 11 deletions test/util/e2e.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"context"
"fmt"
"os"

Expand All @@ -16,7 +15,6 @@ import (
visibility "sigs.k8s.io/kueue/apis/visibility/v1alpha1"
kueueclientset "sigs.k8s.io/kueue/client-go/clientset/versioned"
visibilityv1alpha1 "sigs.k8s.io/kueue/client-go/clientset/versioned/typed/visibility/v1alpha1"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
)

func CreateClientUsingCluster(kContext string) client.Client {
Expand Down Expand Up @@ -64,12 +62,3 @@ func CreateVisibilityClient(user string) visibilityv1alpha1.VisibilityV1alpha1In
visibilityClient := kueueClient.VisibilityV1alpha1()
return visibilityClient
}

func KueueReadyForTesting(ctx context.Context, client client.Client) {
// To verify that webhooks are ready, let's create a simple resourceflavor
resourceKueue := utiltesting.MakeResourceFlavor("default").Obj()
gomega.Eventually(func() error {
return client.Create(context.Background(), resourceKueue)
}, StartUpTimeout, Interval).Should(gomega.Succeed())
ExpectResourceFlavorToBeDeleted(ctx, client, resourceKueue, true)
}

0 comments on commit a8c11f3

Please sign in to comment.