Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thiyyakat committed Oct 22, 2024
1 parent 32a2ae9 commit c582bbe
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pkg/util/provider/drain/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ func (o *Options) RunDrain(ctx context.Context) error {
klog.Errorf("Drain Error: Cordoning of node failed with error: %v", err)
return err
}
stopCh := make(chan struct{})
defer close(stopCh)
if !cache.WaitForCacheSync(stopCh, o.podSynced) {
if !cache.WaitForCacheSync(drainContext.Done(), o.podSynced) {
err := fmt.Errorf("timed out waiting for pod cache to sync")
return err
}
Expand Down Expand Up @@ -363,22 +361,23 @@ func (o *Options) getPodsForDeletion() (pods []corev1.Pod, err error) {
fs := podStatuses{}

for _, pod := range podList {
if pod.Spec.NodeName == o.nodeName {
podOk := true
for _, filt := range []podFilter{mirrorPodFilter, o.localStorageFilter, o.unreplicatedFilter, o.daemonsetFilter} {
filterOk, w, f := filt(*pod)
podOk = podOk && filterOk
if w != nil {
ws[w.string] = append(ws[w.string], pod.Name)
}
if f != nil {
fs[f.string] = append(fs[f.string], pod.Name)
}
if pod.Spec.NodeName != o.nodeName {
continue
}
podOk := true
for _, filt := range []podFilter{mirrorPodFilter, o.localStorageFilter, o.unreplicatedFilter, o.daemonsetFilter} {
filterOk, w, f := filt(*pod)
podOk = podOk && filterOk
if w != nil {
ws[w.string] = append(ws[w.string], pod.Name)
}
if podOk {
pods = append(pods, *pod)
if f != nil {
fs[f.string] = append(fs[f.string], pod.Name)
}
}
if podOk {
pods = append(pods, *pod)
}
}

if len(fs) > 0 {
Expand Down

0 comments on commit c582bbe

Please sign in to comment.