Merge pull request #21724 from freehan/imagepull

fix cascading backoff
This commit is contained in:
Abhi Shah 2016-02-23 17:53:35 -08:00
commit 5f553a218e
2 changed files with 8 additions and 1 deletions

View File

@ -99,7 +99,7 @@ func (puller *imagePuller) PullImage(pod *api.Pod, container *api.Container, pul
}
}
backOffKey := fmt.Sprintf("%s_%s", pod.Name, container.Image)
backOffKey := fmt.Sprintf("%s_%s", pod.UID, container.Image)
if puller.backOff.IsInBackOffSinceUpdate(backOffKey, puller.backOff.Clock.Now()) {
msg := fmt.Sprintf("Back-off pulling image %q", container.Image)
puller.logIt(ref, api.EventTypeNormal, BackOffPullImage, logPrefix, msg, glog.Info)
@ -117,6 +117,7 @@ func (puller *imagePuller) PullImage(pod *api.Pod, container *api.Container, pul
}
}
puller.logIt(ref, api.EventTypeNormal, "Pulled", logPrefix, fmt.Sprintf("Successfully pulled image %q", container.Image), glog.Info)
puller.backOff.DeleteEntry(backOffKey)
puller.backOff.GC()
return nil, ""
}

View File

@ -120,6 +120,12 @@ func (p *Backoff) GC() {
}
}
func (p *Backoff) DeleteEntry(id string) {
p.Lock()
defer p.Unlock()
delete(p.perItemBackoff, id)
}
// Take a lock on *Backoff, before calling initEntryUnsafe
func (p *Backoff) initEntryUnsafe(id string) *backoffEntry {
entry := &backoffEntry{backoff: p.defaultDuration}