Only queue one retry if webhook update fails
Queueing two retries can lead to exponential growth.
Adding a delay before the retry should reduce the number
of failed attempts to update webhooks.
@@ -236,14 +236,23 @@ func (wrc *Register) UpdateWebhookConfigurations(configHandler config.Interface)
}
}
+ retry := false
+
if err := wrc.updateResourceMutatingWebhookConfiguration(nsSelector); err != nil {
logger.Error(err, "unable to update mutatingWebhookConfigurations", "name", getResourceMutatingWebhookConfigName(wrc.serverIP))
- go func() { wrc.UpdateWebhookChan <- true }()
+ retry = true
}
if err := wrc.updateResourceValidatingWebhookConfiguration(nsSelector); err != nil {
logger.Error(err, "unable to update validatingWebhookConfigurations", "name", getResourceValidatingWebhookConfigName(wrc.serverIP))
- go func() { wrc.UpdateWebhookChan <- true }()
+ retry = true
+ }
+
+ if retry {
+ go func() {
+ time.Sleep(1 * time.Second)
+ wrc.UpdateWebhookChan <- true
+ }()
}
}
}
