Add failover flag (#216)
Signed-off-by: RainbowMango <renhongcai@huawei.com>
This commit is contained in:
parent
0de78c0c49
commit
6d7f661908
|
@ -29,6 +29,9 @@ type Options struct {
|
|||
BindAddress string
|
||||
// SecurePort is the port that the server serves at.
|
||||
SecurePort int
|
||||
|
||||
// Failover indicates if scheduler should reschedule on cluster failure.
|
||||
Failover bool
|
||||
}
|
||||
|
||||
// NewOptions builds an default scheduler options.
|
||||
|
@ -56,4 +59,5 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
|
|||
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.")
|
||||
fs.StringVar(&o.BindAddress, "bind-address", defaultBindAddress, "The IP address on which to listen for the --secure-port port.")
|
||||
fs.IntVar(&o.SecurePort, "secure-port", defaultPort, "The secure port on which to serve HTTPS.")
|
||||
fs.BoolVar(&o.Failover, "failover", false, "Reschedule on cluster failure.")
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ func run(opts *options.Options, stopChan <-chan struct{}) error {
|
|||
cancel()
|
||||
}()
|
||||
|
||||
scheduler.Failover = opts.Failover
|
||||
sched := scheduler.NewScheduler(dynamicClientSet, karmadaClient, kubeClientSet)
|
||||
if !opts.LeaderElection.LeaderElect {
|
||||
sched.Run(ctx)
|
||||
|
|
|
@ -40,6 +40,10 @@ const (
|
|||
maxRetries = 15
|
||||
)
|
||||
|
||||
// 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
|
||||
|
@ -225,6 +229,7 @@ func (s *Scheduler) scheduleNext() bool {
|
|||
return false
|
||||
}
|
||||
defer s.queue.Done(key)
|
||||
klog.Infof("Failover flag is: %v", Failover)
|
||||
|
||||
err := s.scheduleOne(key.(string))
|
||||
s.handleErr(err, key)
|
||||
|
|
Loading…
Reference in New Issue