Skip to content

Commit

Permalink
do not delete statefulset pod when update pod
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Jun 29, 2021
1 parent f2a6d39 commit 64b9aba
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,14 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
return
}

if !isPodAlive(newPod) {
isStateful, statefulSetName := isStatefulSetPod(newPod)
if isStateful {
if isStatefulSetPodToDel(c.config.KubeClient, newPod, statefulSetName) {
klog.V(3).Infof("enqueue delete pod %s", key)
c.deletePodQueue.Add(key)
}
} else {
klog.V(3).Infof("enqueue delete pod %s", key)
c.deletePodQueue.Add(key)
}
isStateful, statefulSetName := isStatefulSetPod(newPod)
if !isPodAlive(newPod) && !isStateful {
klog.V(3).Infof("enqueue delete pod %s", key)
c.deletePodQueue.Add(key)
return
}

if newPod.DeletionTimestamp != nil {
if newPod.DeletionTimestamp != nil && !isStateful {
go func() {
// In case node get lost and pod can not be deleted,
// the ipaddress will not be recycled
Expand All @@ -196,6 +189,15 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
return
}

// do not delete statefulset pod unless ownerReferences is deleted
if isStateful {
if isStatefulSetPodToDel(c.config.KubeClient, newPod, statefulSetName) {
klog.V(3).Infof("enqueue delete pod %s", key)
c.deletePodQueue.Add(key)
return
}
}

// pod assigned an ip
if newPod.Annotations[util.AllocatedAnnotation] == "true" &&
newPod.Annotations[util.RoutedAnnotation] != "true" &&
Expand Down

0 comments on commit 64b9aba

Please sign in to comment.