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 23, 2024
1 parent 32a2ae9 commit cd01e68
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/util/provider/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ func StartControllers(s *options.MCServer,
targetCoreInformerFactory.Core().V1().PersistentVolumes(),
controlCoreInformerFactory.Core().V1().Secrets(),
targetCoreInformerFactory.Core().V1().Nodes(),
targetCoreInformerFactory.Core().V1().Pods(),
pdbInformer,
targetCoreInformerFactory.Storage().V1().VolumeAttachments(),
machineSharedInformers.MachineClasses(),
machineSharedInformers.Machines(),
targetCoreInformerFactory.Core().V1().Pods(),
recorder,
s.SafetyOptions,
s.NodeConditions,
Expand Down
33 changes: 16 additions & 17 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 @@ -353,7 +351,7 @@ func (ps podStatuses) Message() string {
func (o *Options) getPodsForDeletion() (pods []corev1.Pod, err error) {
podList, err := o.podLister.List(labels.Everything())
if err != nil {
return nil, err
return
}
if len(podList) == 0 {
klog.Infof("no pods found in store")
Expand All @@ -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
2 changes: 1 addition & 1 deletion pkg/util/provider/machinecontroller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func NewController(
pvInformer coreinformers.PersistentVolumeInformer,
secretInformer coreinformers.SecretInformer,
nodeInformer coreinformers.NodeInformer,
podInformer coreinformers.PodInformer,
pdbInformer policyv1informers.PodDisruptionBudgetInformer,
volumeAttachmentInformer storageinformers.VolumeAttachmentInformer,
machineClassInformer machineinformers.MachineClassInformer,
machineInformer machineinformers.MachineInformer,
podInformer coreinformers.PodInformer,
recorder record.EventRecorder,
safetyOptions options.SafetyOptions,
nodeConditions string,
Expand Down

0 comments on commit cd01e68

Please sign in to comment.