Skip to content

Commit

Permalink
fix: delete pod when marked with deletionTimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Sep 29, 2020
1 parent 4ad7554 commit a197665
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
return
}

if newPod.DeletionTimestamp != nil {
go func() {
// In case node get lost and pod can not be deleted,
// the ipaddress will not be recycled
time.Sleep(time.Duration(*newPod.Spec.TerminationGracePeriodSeconds) * time.Second)
c.deletePodQueue.Add(key)
}()
return
}

// pod assigned an ip
if newPod.Annotations[util.AllocatedAnnotation] == "true" &&
newPod.Annotations[util.RoutedAnnotation] != "true" &&
Expand Down Expand Up @@ -410,7 +420,7 @@ func (c *Controller) handleDeletePod(key string) error {
return nil
}
pod, err := c.podsLister.Pods(namespace).Get(name)
if pod != nil && isPodAlive(pod) {
if pod != nil && pod.DeletionTimestamp == nil && isPodAlive(pod) {
// Pod with same name exists, just return here
return nil
}
Expand Down

0 comments on commit a197665

Please sign in to comment.