Skip to content

Commit

Permalink
Merge pull request kyverno#1369 from realshuting/1366_fix_webhook_reg…
Browse files Browse the repository at this point in the history
…istration

Fix webhook registration
  • Loading branch information
JimBugwadia authored Dec 9, 2020
2 parents d8d9023 + 54b0afb commit 3275326
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 0 additions & 4 deletions pkg/webhookconfig/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ func (t *Monitor) Run(register *Register, eventGen event.Interface, client *dcli
logger.Error(err, "failed to annotate deployment webhook status to failure")
}

cleanUp := make(chan struct{})
register.Remove(cleanUp)
<-cleanUp

if err := register.Register(); err != nil {
logger.Error(err, "Failed to register webhooks")
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/webhookconfig/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package webhookconfig
import (
"errors"
"fmt"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
"sync"
"time"

v1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/go-logr/logr"
"github.com/kyverno/kyverno/pkg/config"
client "github.com/kyverno/kyverno/pkg/dclient"
Expand Down Expand Up @@ -51,13 +52,15 @@ func NewRegister(
}
}

// Register creates admission webhooks configs on cluster
// Register clean up the old webhooks and re-creates admission webhooks configs on cluster
func (wrc *Register) Register() error {
logger := wrc.log
if wrc.serverIP != "" {
logger.Info("Registering webhook", "url", fmt.Sprintf("https://%s", wrc.serverIP))
}

wrc.removeWebhookConfigurations()

errors := make([]string, 0)
if err := wrc.createVerifyMutatingWebhookConfiguration(); err != nil {
errors = append(errors, err.Error())
Expand Down

0 comments on commit 3275326

Please sign in to comment.