mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-21 01:26:28 +00:00
fix petset update(pet) retries bug
Change-Id: I92e2b653ab78fca72ae41cf87945d90fbbc67f44
This commit is contained in:
parent
a062d9fe3b
commit
3de4695057
@ -197,23 +197,26 @@ func (p *apiServerPetClient) Create(pet *pcb) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update updates the pet in the 'pet' pcb to match the pet in the 'expectedPet' pcb.
|
// Update updates the pet in the 'pet' pcb to match the pet in the 'expectedPet' pcb.
|
||||||
|
// If the pod object of a pet which to be updated has been changed in server side, we
|
||||||
|
// will get the actual value and set pet identity before retries.
|
||||||
func (p *apiServerPetClient) Update(pet *pcb, expectedPet *pcb) (updateErr error) {
|
func (p *apiServerPetClient) Update(pet *pcb, expectedPet *pcb) (updateErr error) {
|
||||||
var getErr error
|
|
||||||
pc := podClient(p.c, pet.parent.Namespace)
|
pc := podClient(p.c, pet.parent.Namespace)
|
||||||
|
|
||||||
pod, needsUpdate, err := copyPetID(pet, expectedPet)
|
for i := 0; ; i++ {
|
||||||
|
updatePod, needsUpdate, err := copyPetID(pet, expectedPet)
|
||||||
if err != nil || !needsUpdate {
|
if err != nil || !needsUpdate {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
glog.Infof("Resetting pet %v to match PetSet %v spec", pod.Name, pet.parent.Name)
|
glog.Infof("Resetting pet %v/%v to match PetSet %v spec", pet.pod.Namespace, pet.pod.Name, pet.parent.Name)
|
||||||
for i, p := 0, &pod; ; i++ {
|
_, updateErr = pc.Update(&updatePod)
|
||||||
_, updateErr = pc.Update(p)
|
|
||||||
if updateErr == nil || i >= updateRetries {
|
if updateErr == nil || i >= updateRetries {
|
||||||
return updateErr
|
return updateErr
|
||||||
}
|
}
|
||||||
if p, getErr = pc.Get(pod.Name); getErr != nil {
|
getPod, getErr := pc.Get(updatePod.Name)
|
||||||
|
if getErr != nil {
|
||||||
return getErr
|
return getErr
|
||||||
}
|
}
|
||||||
|
pet.pod = getPod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user