Skip to content

Commit

Permalink
delete pod after TerminationGracePeriodSeconds (#1984)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Oct 24, 2022
1 parent 87996f7 commit 113f62f
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 @@ -226,16 +226,20 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
}

// do not delete statefulset pod unless ownerReferences is deleted
if isStateful {
if isStatefulSetPodToDel(c.config.KubeClient, newPod, statefulSetName) {
if isStateful && isStatefulSetPodToDel(c.config.KubeClient, newPod, statefulSetName) {
go func() {
klog.V(3).Infof("enqueue delete pod %s", key)
time.Sleep(time.Duration(*newPod.Spec.TerminationGracePeriodSeconds) * time.Second)
c.deletePodQueue.Add(newObj)
return
}
}()
return
}
if isVmPod && c.isVmPodToDel(newPod, vmName) {
klog.V(3).Infof("enqueue delete pod %s", key)
c.deletePodQueue.Add(newObj)
go func() {
klog.V(3).Infof("enqueue delete pod %s", key)
time.Sleep(time.Duration(*newPod.Spec.TerminationGracePeriodSeconds) * time.Second)
c.deletePodQueue.Add(newObj)
}()
return
}

Expand Down

0 comments on commit 113f62f

Please sign in to comment.