mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
honor timeout when dispatch
This commit is contained in:
parent
1cd9162c15
commit
e1e9ee5311
@ -101,7 +101,11 @@ func (a *mutatingDispatcher) callAttrMutatingHook(ctx context.Context, h *v1beta
|
|||||||
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
response := &admissionv1beta1.AdmissionReview{}
|
response := &admissionv1beta1.AdmissionReview{}
|
||||||
if err := client.Post().Context(ctx).Body(&request).Do().Into(response); err != nil {
|
r := client.Post().Context(ctx).Body(&request)
|
||||||
|
if h.TimeoutSeconds != nil {
|
||||||
|
r = r.Timeout(time.Duration(*h.TimeoutSeconds) * time.Second)
|
||||||
|
}
|
||||||
|
if err := r.Do().Into(response); err != nil {
|
||||||
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,11 @@ func (d *validatingDispatcher) callHook(ctx context.Context, h *v1beta1.Webhook,
|
|||||||
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
response := &admissionv1beta1.AdmissionReview{}
|
response := &admissionv1beta1.AdmissionReview{}
|
||||||
if err := client.Post().Context(ctx).Body(&request).Do().Into(response); err != nil {
|
r := client.Post().Context(ctx).Body(&request)
|
||||||
|
if h.TimeoutSeconds != nil {
|
||||||
|
r = r.Timeout(time.Duration(*h.TimeoutSeconds) * time.Second)
|
||||||
|
}
|
||||||
|
if err := r.Do().Into(response); err != nil {
|
||||||
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
return &webhook.ErrCallingWebhook{WebhookName: h.Name, Reason: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user