@@ -416,7 +416,7 @@ func (o *Options) evictPod(ctx context.Context, pod *corev1.Pod, policyGroupVers
416416 DeleteOptions : deleteOptions ,
417417 }
418418 klog .V (3 ).Infof ("Attempting to evict the pod:%q from node %q" , pod .Name , o .nodeName )
419- // TODO: Remember to change the URL manipulation func when Evction 's version change
419+ // TODO: Remember to change the URL manipulation func when Eviction 's version change
420420 return o .client .PolicyV1beta1 ().Evictions (eviction .Namespace ).Evict (ctx , eviction )
421421}
422422
@@ -682,7 +682,7 @@ func (o *Options) evictPodsWithPv(ctx context.Context, attemptEvict bool, pods [
682682}
683683
684684// checkAndDeleteWorker is a helper method that check if volumeAttachmentHandler
685- // is supported and delete's the worker from the list of event handlers
685+ // is supported and deletes the worker from the list of event handlers
686686func (o * Options ) checkAndDeleteWorker (volumeAttachmentEventCh chan * storagev1.VolumeAttachment ) {
687687 if o .volumeAttachmentHandler != nil {
688688 o .volumeAttachmentHandler .DeleteWorker (volumeAttachmentEventCh )
@@ -695,11 +695,11 @@ func (o *Options) evictPodsWithPVInternal(
695695 pods []* corev1.Pod ,
696696 podVolumeInfoMap map [string ]PodVolumeInfo ,
697697 policyGroupVersion string ,
698- _ func (namespace , name string ) (* corev1.Pod , error ),
698+ getPodFn func (namespace , name string ) (* corev1.Pod , error ),
699699 returnCh chan error ,
700700) (remainingPods []* corev1.Pod , fastTrack bool ) {
701701 var (
702- retryPods []* corev1.Pod
702+ retryPods , pendingPods []* corev1.Pod
703703 )
704704
705705 for i , pod := range pods {
@@ -817,7 +817,18 @@ func (o *Options) evictPodsWithPVInternal(
817817 returnCh <- nil
818818 }
819819
820- return retryPods , false
820+ for _ , pod := range retryPods {
821+ p , err := getPodFn (pod .Namespace , pod .Name )
822+ if apierrors .IsNotFound (err ) || (p != nil && p .ObjectMeta .UID != pod .ObjectMeta .UID ) {
823+ returnCh <- nil
824+ continue
825+ } else if err != nil {
826+ klog .Errorf ("error fetching pod %s status. Retrying. Err: %v" , pod .Name , err )
827+ }
828+ pendingPods = append (pendingPods , pod )
829+ }
830+
831+ return pendingPods , false
821832}
822833
823834func (o * Options ) getPersistentVolumeNamesForPod (pod * corev1.Pod ) []string {
0 commit comments