Skip to content

Commit 6d7f661

Browse files
authored
Add failover flag (#216)
Signed-off-by: RainbowMango <[email protected]>
1 parent 0de78c0 commit 6d7f661

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

cmd/scheduler/app/options/options.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ type Options struct {
2929
BindAddress string
3030
// SecurePort is the port that the server serves at.
3131
SecurePort int
32+
33+
// Failover indicates if scheduler should reschedule on cluster failure.
34+
Failover bool
3235
}
3336

3437
// NewOptions builds an default scheduler options.
@@ -56,4 +59,5 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
5659
fs.StringVar(&o.Master, "master", o.Master, "The address of the Kubernetes API server. Overrides any value in KubeConfig. Only required if out-of-cluster.")
5760
fs.StringVar(&o.BindAddress, "bind-address", defaultBindAddress, "The IP address on which to listen for the --secure-port port.")
5861
fs.IntVar(&o.SecurePort, "secure-port", defaultPort, "The secure port on which to serve HTTPS.")
62+
fs.BoolVar(&o.Failover, "failover", false, "Reschedule on cluster failure.")
5963
}

cmd/scheduler/app/scheduler.go

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func run(opts *options.Options, stopChan <-chan struct{}) error {
6060
cancel()
6161
}()
6262

63+
scheduler.Failover = opts.Failover
6364
sched := scheduler.NewScheduler(dynamicClientSet, karmadaClient, kubeClientSet)
6465
if !opts.LeaderElection.LeaderElect {
6566
sched.Run(ctx)

pkg/scheduler/scheduler.go

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ const (
4040
maxRetries = 15
4141
)
4242

43+
// Failover indicates if the scheduler should performs re-scheduler in case of cluster failure.
44+
// TODO(RainbowMango): Remove the temporary solution by introducing feature flag
45+
var Failover bool
46+
4347
// Scheduler is the scheduler schema, which is used to schedule a specific resource to specific clusters
4448
type Scheduler struct {
4549
DynamicClient dynamic.Interface
@@ -225,6 +229,7 @@ func (s *Scheduler) scheduleNext() bool {
225229
return false
226230
}
227231
defer s.queue.Done(key)
232+
klog.Infof("Failover flag is: %v", Failover)
228233

229234
err := s.scheduleOne(key.(string))
230235
s.handleErr(err, key)

0 commit comments

Comments
 (0)