mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
nomad: create system scheduler as needed
This commit is contained in:
@@ -99,10 +99,6 @@ type Server struct {
|
||||
// plans that are waiting to be assessed by the leader
|
||||
planQueue *PlanQueue
|
||||
|
||||
// systemSched is the special system scheduler used for
|
||||
// various maintanence and book keeping.
|
||||
systemSched *SystemScheduler
|
||||
|
||||
left bool
|
||||
shutdown bool
|
||||
shutdownCh chan struct{}
|
||||
@@ -161,9 +157,6 @@ func NewServer(config *Config) (*Server, error) {
|
||||
shutdownCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
// Create the system scheduler
|
||||
s.systemSched = &SystemScheduler{srv: s}
|
||||
|
||||
// Initialize the RPC layer
|
||||
// TODO: TLS...
|
||||
if err := s.setupRPC(nil); err != nil {
|
||||
|
||||
28
nomad/system_sched.go
Normal file
28
nomad/system_sched.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package nomad
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/scheduler"
|
||||
)
|
||||
|
||||
// SystemScheduler is a special "scheduler" that is registered
|
||||
// as "system". It is used to run various administrative work
|
||||
// across the cluster.
|
||||
type SystemScheduler struct {
|
||||
srv *Server
|
||||
snap *StateSnapshot
|
||||
}
|
||||
|
||||
// NewSystemScheduler is used to return a new system scheduler instance
|
||||
func NewSystemScheduler(srv *Server, snap *StateSnapshot) scheduler.Scheduler {
|
||||
s := &SystemScheduler{
|
||||
srv: srv,
|
||||
snap: snap,
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Process is used to implement the scheduler.Scheduler interface
|
||||
func (s *SystemScheduler) Process(*structs.Evaluation) error {
|
||||
return nil
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func (w *Worker) invokeScheduler(eval *structs.Evaluation) error {
|
||||
// Create the scheduler, or use the special system scheduler
|
||||
var sched scheduler.Scheduler
|
||||
if eval.Type == structs.JobTypeSystem {
|
||||
sched = w.srv.systemSched
|
||||
sched = NewSystemScheduler(w.srv, snap)
|
||||
} else {
|
||||
sched, err = scheduler.NewScheduler(eval.Type, snap, w)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user