Skip to content

Commit

Permalink
Add sleep before applying webhook config
Browse files Browse the repository at this point in the history
  • Loading branch information
dramich committed Sep 29, 2020
1 parent 028bc94 commit 7c18e30
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/admission/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package admission
import (
"context"
"net/http"
"time"

"github.com/rancher/dynamiclistener"
"github.com/rancher/dynamiclistener/server"
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/generated/controllers/core"
"github.com/rancher/wrangler/pkg/schemes"
"github.com/sirupsen/logrus"
v1 "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -60,6 +62,10 @@ func listenAndServe(ctx context.Context, cfg *rest.Config, handler http.Handler)
return nil, nil
}

logrus.Info("Sleeping for 15 seconds then applying webhook config")
// Sleep here to make sure server is listening and all caches are primed
time.Sleep(15 * time.Second)

return secret, apply.WithOwner(secret).ApplyObjects(&v1.ValidatingWebhookConfiguration{
ObjectMeta: metav1.ObjectMeta{
Name: "rancher.cattle.io",
Expand Down

0 comments on commit 7c18e30

Please sign in to comment.