From 1bb6ed9bdc0fb960d0acedc575a59de1306006ca Mon Sep 17 00:00:00 2001 From: JoshVanL Date: Thu, 5 Mar 2020 23:30:50 +0000 Subject: [PATCH] Checks error for loading audit webhook config to prevent panic Signed-off-by: JoshVanL --- .../k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go index 09933733102..e75052ee352 100644 --- a/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go +++ b/staging/src/k8s.io/apiserver/plugin/pkg/audit/webhook/webhook.go @@ -64,8 +64,12 @@ func retryOnError(err error) bool { func loadWebhook(configFile string, groupVersion schema.GroupVersion, initialBackoff time.Duration, customDial utilnet.DialFunc) (*webhook.GenericWebhook, error) { w, err := webhook.NewGenericWebhook(audit.Scheme, audit.Codecs, configFile, []schema.GroupVersion{groupVersion}, initialBackoff, customDial) + if err != nil { + return nil, err + } + w.ShouldRetry = retryOnError - return w, err + return w, nil } type backend struct {