Skip to content

Commit

Permalink
clean_up_the_failover_flag
Browse files Browse the repository at this point in the history
Signed-off-by: zhongjun.li <[email protected]>
  • Loading branch information
learner0810 committed Oct 27, 2021
1 parent 1f87ca9 commit 3bdd019
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion cmd/scheduler/app/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func run(opts *options.Options, stopChan <-chan struct{}) error {
cancel()
}()

scheduler.Failover = opts.Failover
sched := scheduler.NewScheduler(dynamicClientSet, karmadaClient, kubeClientSet, opts)
if !opts.LeaderElection.LeaderElect {
sched.Run(ctx)
Expand Down
14 changes: 7 additions & 7 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ const (
scheduleSuccessMessage = "the binding has been scheduled"
)

// Failover indicates if the scheduler should performs re-scheduler in case of cluster failure.
// TODO(RainbowMango): Remove the temporary solution by introducing feature flag
var Failover bool

// Scheduler is the scheduler schema, which is used to schedule a specific resource to specific clusters
type Scheduler struct {
DynamicClient dynamic.Interface
Expand All @@ -98,6 +94,9 @@ type Scheduler struct {
schedulerEstimatorCache *estimatorclient.SchedulerEstimatorCache
schedulerEstimatorPort int
schedulerEstimatorWorker util.AsyncWorker

// Failover indicates if the scheduler should performs re-scheduler in case of cluster failure.
Failover bool
}

// NewScheduler instantiates a scheduler
Expand Down Expand Up @@ -134,6 +133,7 @@ func NewScheduler(dynamicClient dynamic.Interface, karmadaClient karmadaclientse
Algorithm: algorithm,
schedulerCache: schedulerCache,
enableSchedulerEstimator: opts.EnableSchedulerEstimator,
Failover: opts.Failover,
}
if opts.EnableSchedulerEstimator {
sched.schedulerEstimatorCache = estimatorclient.NewSchedulerEstimatorCache()
Expand Down Expand Up @@ -412,7 +412,7 @@ func (s *Scheduler) scheduleNext() bool {
klog.Infof("Reschedule binding(%s) as replicas scaled down or scaled up", keys)
metrics.BindingSchedule(string(ScaleSchedule), metrics.SinceInSeconds(start), err)
case FailoverSchedule:
if Failover {
if s.Failover {
err = s.rescheduleOne(keys)
klog.Infof("Reschedule binding(%s) as cluster failure", keys)
metrics.BindingSchedule(string(FailoverSchedule), metrics.SinceInSeconds(start), err)
Expand Down Expand Up @@ -554,9 +554,9 @@ func (s *Scheduler) updateCluster(_, newObj interface{}) {

// Check if cluster becomes failure
if meta.IsStatusConditionPresentAndEqual(newCluster.Status.Conditions, clusterv1alpha1.ClusterConditionReady, metav1.ConditionFalse) {
klog.Infof("Found cluster(%s) failure and failover flag is %v", newCluster.Name, Failover)
klog.Infof("Found cluster(%s) failure and failover flag is %v", newCluster.Name, s.Failover)

if Failover { // Trigger reschedule on cluster failure only when flag is true.
if s.Failover { // Trigger reschedule on cluster failure only when flag is true.
s.enqueueAffectedBinding(newCluster.Name)
s.enqueueAffectedClusterBinding(newCluster.Name)
return
Expand Down

0 comments on commit 3bdd019

Please sign in to comment.