Skip to content

Commit

Permalink
Ignore context canceled from validate and mutate webhook failopen metric
Browse files Browse the repository at this point in the history
  • Loading branch information
divyasri537 committed Aug 17, 2023
1 parent 00dfa06 commit 6c8436b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -198,6 +198,10 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr admission.Attrib
}

if callErr, ok := err.(*webhookutil.ErrCallingWebhook); ok {
if ctx.Err() == context.Canceled {
klog.Warningf("Context Canceled when calling webhook %v", hook.Name)
return err
}
if ignoreClientCallFailures {
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "admit")
Expand Down
Expand Up @@ -193,6 +193,10 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr admission.Attr
}

if callErr, ok := err.(*webhookutil.ErrCallingWebhook); ok {
if ctx.Err() == context.Canceled {
klog.Warningf("Context Canceled when calling webhook %v", hook.Name)
return
}
if ignoreClientCallFailures {
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "validating")
Expand Down

0 comments on commit 6c8436b

Please sign in to comment.