Merge pull request #90299 from josephw/send-static-retry-after-when-hitting-pod-disruption-budget

Set a static Retry-After when evicting a pod is not allowed.
This commit is contained in:
Kubernetes Prow Robot 2021-01-11 07:19:07 -08:00 committed by GitHub
commit 94a623a45a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,11 +303,11 @@ func resourceVersionIsUnset(options *metav1.DeleteOptions) bool {
} }
func createTooManyRequestsError(name string) error { func createTooManyRequestsError(name string) error {
// TODO(mml): Add a Retry-After header. Once there are time-based // TODO: Once there are time-based
// budgets, we can sometimes compute a sensible suggested value. But // budgets, we can sometimes compute a sensible suggested value. But
// even without that, we can give a suggestion (10 minutes?) that // even without that, we can give a suggestion (even if small) that
// prevents well-behaved clients from hammering us. // prevents well-behaved clients from hammering us.
err := errors.NewTooManyRequests("Cannot evict pod as it would violate the pod's disruption budget.", 0) err := errors.NewTooManyRequests("Cannot evict pod as it would violate the pod's disruption budget.", 10)
err.ErrStatus.Details.Causes = append(err.ErrStatus.Details.Causes, metav1.StatusCause{Type: "DisruptionBudget", Message: fmt.Sprintf("The disruption budget %s is still being processed by the server.", name)}) err.ErrStatus.Details.Causes = append(err.ErrStatus.Details.Causes, metav1.StatusCause{Type: "DisruptionBudget", Message: fmt.Sprintf("The disruption budget %s is still being processed by the server.", name)})
return err return err
} }