From fb61854bd284b9d095b10a722369a3a656ba2dea Mon Sep 17 00:00:00 2001 From: Joseph Walton Date: Mon, 20 Apr 2020 23:56:27 +1000 Subject: [PATCH] Set a static Retry-After when evicting a pod is not allowed. Follow the original TODO from back in c86b84c with the errors added in d3be1ac. Edit the TODO to make clear that a dynamic response would still be ideal. Dramatically reduce the time based on suggestion in PR, and remove name from TODO as not currently active. --- pkg/registry/core/pod/storage/eviction.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/registry/core/pod/storage/eviction.go b/pkg/registry/core/pod/storage/eviction.go index 28bf90e380a..2cea974599e 100644 --- a/pkg/registry/core/pod/storage/eviction.go +++ b/pkg/registry/core/pod/storage/eviction.go @@ -303,11 +303,11 @@ func resourceVersionIsUnset(options *metav1.DeleteOptions) bool { } 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 - // 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. - 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)}) return err }