Merge pull request #32482 from m1093782566/m109-pet-set-fix-update-bug

Automatic merge from submit-queue

[Pet Set] Fix losing pet updated information between update retries

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md
3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes
-->

**What this PR does / why we need it**:

Address #32481

@bprashanth
This commit is contained in:
Kubernetes Submit Queue 2016-09-20 05:16:04 -07:00 committed by GitHub
commit 4a176600fc

View File

@ -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.
// 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) {
var getErr error
pc := podClient(p.c, pet.parent.Namespace)
pod, needsUpdate, err := copyPetID(pet, expectedPet)
if err != nil || !needsUpdate {
return err
}
glog.Infof("Resetting pet %v to match PetSet %v spec", pod.Name, pet.parent.Name)
for i, p := 0, &pod; ; i++ {
_, updateErr = pc.Update(p)
for i := 0; ; i++ {
updatePod, needsUpdate, err := copyPetID(pet, expectedPet)
if err != nil || !needsUpdate {
return err
}
glog.Infof("Resetting pet %v/%v to match PetSet %v spec", pet.pod.Namespace, pet.pod.Name, pet.parent.Name)
_, updateErr = pc.Update(&updatePod)
if updateErr == nil || i >= updateRetries {
return updateErr
}
if p, getErr = pc.Get(pod.Name); getErr != nil {
getPod, getErr := pc.Get(updatePod.Name)
if getErr != nil {
return getErr
}
pet.pod = getPod
}
}