Merge pull request #79736 from ricky1993/fix_eviction_conflict

Get the pdb of current version when conflict instead of relisting
This commit is contained in:
Kubernetes Prow Robot 2019-07-04 06:56:39 -07:00 committed by GitHub
commit 7bbc130f5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -133,7 +133,7 @@ func (r *EvictionREST) Create(ctx context.Context, obj runtime.Object, createVal
}
var rtStatus *metav1.Status
var pdbName string
err = retry.RetryOnConflict(EvictionsRetry, func() error {
err = func() error {
pdbs, err := r.getPodDisruptionBudgets(ctx, pod)
if err != nil {
return err
@ -146,19 +146,33 @@ func (r *EvictionREST) Create(ctx context.Context, obj runtime.Object, createVal
Code: 500,
}
return nil
} else if len(pdbs) == 1 {
pdb := pdbs[0]
pdbName = pdb.Name
}
if len(pdbs) == 0 {
return nil
}
pdb := &pdbs[0]
pdbName = pdb.Name
refresh := false
err = retry.RetryOnConflict(EvictionsRetry, func() error {
if refresh {
pdb, err = r.podDisruptionBudgetClient.PodDisruptionBudgets(pod.Namespace).Get(pdbName, metav1.GetOptions{})
if err != nil {
return err
}
}
// Try to verify-and-decrement
// If it was false already, or if it becomes false during the course of our retries,
// raise an error marked as a 429.
if err := r.checkAndDecrement(pod.Namespace, pod.Name, pdb, dryrun.IsDryRun(deletionOptions.DryRun)); err != nil {
if err = r.checkAndDecrement(pod.Namespace, pod.Name, *pdb, dryrun.IsDryRun(deletionOptions.DryRun)); err != nil {
refresh = true
return err
}
}
return nil
})
return nil
})
return err
}()
if err == wait.ErrWaitTimeout {
err = errors.NewTimeoutError(fmt.Sprintf("couldn't update PodDisruptionBudget %q due to conflicts", pdbName), 10)
}