mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-20 09:05:26 +00:00
Skip apiserver_admission_webhook_request_total during context-canceled
This commit is contained in:
parent
1732b23a34
commit
d3c506133f
@ -168,6 +168,10 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr admission.Attrib
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
switch err := err.(type) {
|
switch err := err.(type) {
|
||||||
case *webhookutil.ErrCallingWebhook:
|
case *webhookutil.ErrCallingWebhook:
|
||||||
|
if ctx.Err() == context.Canceled {
|
||||||
|
klog.Warningf("Context Canceled when calling webhook %v", hook.Name)
|
||||||
|
return err
|
||||||
|
}
|
||||||
if !ignoreClientCallFailures {
|
if !ignoreClientCallFailures {
|
||||||
rejected = true
|
rejected = true
|
||||||
admissionmetrics.Metrics.ObserveWebhookRejection(ctx, hook.Name, "admit", string(versionedAttr.Attributes.GetOperation()), admissionmetrics.WebhookRejectionCallingWebhookError, int(err.Status.ErrStatus.Code))
|
admissionmetrics.Metrics.ObserveWebhookRejection(ctx, hook.Name, "admit", string(versionedAttr.Attributes.GetOperation()), admissionmetrics.WebhookRejectionCallingWebhookError, int(err.Status.ErrStatus.Code))
|
||||||
@ -198,10 +202,6 @@ func (a *mutatingDispatcher) Dispatch(ctx context.Context, attr admission.Attrib
|
|||||||
}
|
}
|
||||||
|
|
||||||
if callErr, ok := err.(*webhookutil.ErrCallingWebhook); ok {
|
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 {
|
if ignoreClientCallFailures {
|
||||||
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
||||||
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "admit")
|
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "admit")
|
||||||
|
@ -173,6 +173,10 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr admission.Attr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
switch err := err.(type) {
|
switch err := err.(type) {
|
||||||
case *webhookutil.ErrCallingWebhook:
|
case *webhookutil.ErrCallingWebhook:
|
||||||
|
if ctx.Err() == context.Canceled {
|
||||||
|
klog.Warningf("Context Canceled when calling webhook %v", hook.Name)
|
||||||
|
return
|
||||||
|
}
|
||||||
if !ignoreClientCallFailures {
|
if !ignoreClientCallFailures {
|
||||||
rejected = true
|
rejected = true
|
||||||
admissionmetrics.Metrics.ObserveWebhookRejection(ctx, hook.Name, "validating", string(versionedAttr.Attributes.GetOperation()), admissionmetrics.WebhookRejectionCallingWebhookError, int(err.Status.ErrStatus.Code))
|
admissionmetrics.Metrics.ObserveWebhookRejection(ctx, hook.Name, "validating", string(versionedAttr.Attributes.GetOperation()), admissionmetrics.WebhookRejectionCallingWebhookError, int(err.Status.ErrStatus.Code))
|
||||||
@ -193,10 +197,6 @@ func (d *validatingDispatcher) Dispatch(ctx context.Context, attr admission.Attr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if callErr, ok := err.(*webhookutil.ErrCallingWebhook); ok {
|
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 {
|
if ignoreClientCallFailures {
|
||||||
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
klog.Warningf("Failed calling webhook, failing open %v: %v", hook.Name, callErr)
|
||||||
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "validating")
|
admissionmetrics.Metrics.ObserveWebhookFailOpen(ctx, hook.Name, "validating")
|
||||||
|
Loading…
Reference in New Issue
Block a user