mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
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:
commit
7bbc130f5e
@ -133,7 +133,7 @@ func (r *EvictionREST) Create(ctx context.Context, obj runtime.Object, createVal
|
|||||||
}
|
}
|
||||||
var rtStatus *metav1.Status
|
var rtStatus *metav1.Status
|
||||||
var pdbName string
|
var pdbName string
|
||||||
err = retry.RetryOnConflict(EvictionsRetry, func() error {
|
err = func() error {
|
||||||
pdbs, err := r.getPodDisruptionBudgets(ctx, pod)
|
pdbs, err := r.getPodDisruptionBudgets(ctx, pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -146,19 +146,33 @@ func (r *EvictionREST) Create(ctx context.Context, obj runtime.Object, createVal
|
|||||||
Code: 500,
|
Code: 500,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
} else if len(pdbs) == 1 {
|
}
|
||||||
pdb := pdbs[0]
|
if len(pdbs) == 0 {
|
||||||
pdbName = pdb.Name
|
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
|
// Try to verify-and-decrement
|
||||||
|
|
||||||
// If it was false already, or if it becomes false during the course of our retries,
|
// If it was false already, or if it becomes false during the course of our retries,
|
||||||
// raise an error marked as a 429.
|
// 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 err
|
||||||
}
|
}
|
||||||
}
|
return nil
|
||||||
return nil
|
})
|
||||||
})
|
return err
|
||||||
|
}()
|
||||||
if err == wait.ErrWaitTimeout {
|
if err == wait.ErrWaitTimeout {
|
||||||
err = errors.NewTimeoutError(fmt.Sprintf("couldn't update PodDisruptionBudget %q due to conflicts", pdbName), 10)
|
err = errors.NewTimeoutError(fmt.Sprintf("couldn't update PodDisruptionBudget %q due to conflicts", pdbName), 10)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user