You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow deletion of unhealthy pods if enough healthy
Currently, if you have a PDB with 0 disruptions
available and you attempt to evict a non-healthy
pod, the eviction request will always fail. This
is because the eviction API does not currently
take in to account that the pod you are removing
is the unhealthy one.
This commit accounts for trying to evict an
unhealthy pod as long as there are enough healthy
pods to satisfy the PDB's requirements. To
protect against race conditions, a ResourceVersion
constraint is enforced. This will ensure that
the target pod does not go healthy and allow
any race condition to occur which might disrupt
too many pods at once.
This commit also eliminates superfluous class to
DeepCopy for the deleteOptions struct.
// TODO(mml): Add a Retry-After header. Once there are time-based
307
+
// budgets, we can sometimes compute a sensible suggested value. But
308
+
// even without that, we can give a suggestion (10 minutes?) that
309
+
// prevents well-behaved clients from hammering us.
310
+
err:=errors.NewTooManyRequests("Cannot evict pod as it would violate the pod's disruption budget.", 0)
311
+
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)})
312
+
returnerr
313
+
}
314
+
271
315
// checkAndDecrement checks if the provided PodDisruptionBudget allows any disruption.
// TODO(mml): Add a Retry-After header. Once there are time-based
275
-
// budgets, we can sometimes compute a sensible suggested value. But
276
-
// even without that, we can give a suggestion (10 minutes?) that
277
-
// prevents well-behaved clients from hammering us.
278
-
err:=errors.NewTooManyRequests("Cannot evict pod as it would violate the pod's disruption budget.", 0)
279
-
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.", pdb.Name)})
280
-
returnerr
318
+
319
+
returncreateTooManyRequestsError(pdb.Name)
281
320
}
282
321
ifpdb.Status.DisruptionsAllowed<0 {
283
322
returnerrors.NewForbidden(policy.Resource("poddisruptionbudget"), pdb.Name, fmt.Errorf("pdb disruptions allowed is negative"))
0 commit comments