Skip to content

Commit

Permalink
koord-descheduler: add arbitration to migration controller.
Browse files Browse the repository at this point in the history
1.remove lock in migration Reconciler;
2.move codes from migration/filter.go to migration/controller.go;
3.remove some comments;
4.remove explicit initialization of mu in arbitration/filter.go;

Signed-off-by: baowj <[email protected]>
  • Loading branch information
baowj-678 committed Sep 22, 2023
1 parent d7c6f09 commit cbb098d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
1 change: 0 additions & 1 deletion pkg/descheduler/controllers/migration/arbitrator/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func NewFilter(args *deschedulerconfig.MigrationControllerArgs, handle framework
client: options.Manager.GetClient(),
args: args,
controllerFinder: controllerFinder,
mu: sync.Mutex{},
clock: clock.RealClock{},
}
if err := f.initFilters(args, handle); err != nil {
Expand Down
13 changes: 9 additions & 4 deletions pkg/descheduler/controllers/migration/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"strconv"
"sync"
"time"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -76,7 +75,6 @@ type Reconciler struct {
assumedCache *assumedCache
clock clock.Clock

lock sync.Mutex
filter arbitrator.MigrationFilter
}

Expand All @@ -100,14 +98,12 @@ func New(args runtime.Object, handle framework.Handle) (framework.Plugin, error)
return nil, err
}

// New filter
filter, arbitrationFilter, err := arbitrator.NewFilter(controllerArgs, handle)
if err != nil {
return nil, err
}
r.filter = filter

// New Arbitrator
a, err := arbitrator.New(controllerArgs.ArbitrationArgs, arbitrator.Options{
Client: r.Client,
EventRecorder: r.eventRecorder,
Expand Down Expand Up @@ -928,3 +924,12 @@ func (r *Reconciler) updateCondition(ctx context.Context, job *sev1alpha1.PodMig
}
return nil
}

// Filter checks if a pod can be evicted
func (r *Reconciler) Filter(pod *corev1.Pod) bool {
return r.filter.Filter(pod)
}

func (r *Reconciler) PreEvictionFilter(pod *corev1.Pod) bool {
return r.filter.PreEvictionFilter(pod)
}
30 changes: 0 additions & 30 deletions pkg/descheduler/controllers/migration/filter.go

This file was deleted.

0 comments on commit cbb098d

Please sign in to comment.