1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

Use non-blocking channel send for UpdateWebhookChan (#4204) (#4247)

If the channel send is blocked then there is already an
update queued, and there is no point waiting to queue
another one.

In profiling, the channel send in monitor.go has been
seen to "leak" goroutines as the channel is not being
read from fast enough, but the root cause is not known.

Signed-off-by: Thomas Hartland <thomas.hartland@diamond.ac.uk>

Co-authored-by: Thomas Hartland <11710676+tghartland@users.noreply.github.com>
This commit is contained in:
Prateek Pandey 2022-07-21 19:37:56 +05:30 committed by GitHub
parent a7cf6e7c05
commit 4d685c798f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -116,8 +116,12 @@ func (t *Monitor) Run(register *Register, certRenewer *tls.CertRenewer, eventGen
// update namespaceSelector every 30 seconds
go func() {
if register.autoUpdateWebhooks {
logger.V(4).Info("updating webhook configurations for namespaceSelector with latest kyverno ConfigMap")
register.UpdateWebhookChan <- true
select {
case register.UpdateWebhookChan <- true:
logger.V(4).Info("updating webhook configurations for namespaceSelector with latest kyverno ConfigMap")
default:
logger.V(4).Info("skipped sending update webhook signal as the channel was blocking")
}
}
}()

View file

@ -217,7 +217,12 @@ func (wrc *Register) UpdateWebhookConfigurations(configHandler config.Configurat
if retry {
go func() {
time.Sleep(1 * time.Second)
wrc.UpdateWebhookChan <- true
select {
case wrc.UpdateWebhookChan <- true:
return
default:
return
}
}()
}
}