Skip to content

Commit

Permalink
fix: if pod is evicted, recycle address
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Mar 4, 2020
1 parent 1bdb2a8 commit 9211486
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (c *Controller) enqueueAddPod(obj interface{}) {
return
}
if p.Status.Phase == v1.PodFailed && p.Status.Reason == "Evicted" {
c.deletePodQueue.Add(key)
return
}

Expand Down Expand Up @@ -139,17 +140,20 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
if newPod.Spec.HostNetwork {
return
}

var key string
var err error
if key, err = cache.MetaNamespaceKeyFunc(newObj); err != nil {
utilruntime.HandleError(err)
return
}

if newPod.Status.Phase == v1.PodFailed && newPod.Status.Reason == "Evicted" {
c.deletePodQueue.Add(key)
return
}
// pod assigned an ip
if oldPod.Status.PodIP != newPod.Status.PodIP {
var key string
var err error
if key, err = cache.MetaNamespaceKeyFunc(newObj); err != nil {
utilruntime.HandleError(err)
return
}
klog.V(3).Infof("enqueue update pod %s", key)
c.updatePodQueue.Add(key)
}
Expand Down

0 comments on commit 9211486

Please sign in to comment.