mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
nomad: adding skeleton no-op plan evaluator
This commit is contained in:
@@ -100,7 +100,8 @@ func (s *Server) establishLeadership() error {
|
||||
// Enable the plan queue, since we are now the leader
|
||||
s.planQueue.SetEnabled(true)
|
||||
|
||||
// TODO: Start the plan evaluator
|
||||
// Start the plan evaluator
|
||||
go s.planApply()
|
||||
|
||||
// Enable the eval broker, since we are now the leader
|
||||
s.evalBroker.SetEnabled(true)
|
||||
|
||||
28
nomad/plan_apply.go
Normal file
28
nomad/plan_apply.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package nomad
|
||||
|
||||
import "github.com/hashicorp/nomad/nomad/structs"
|
||||
|
||||
// planApply is a long lived goroutine that reads plan allocations from
|
||||
// the plan queue, determines if they can be applied safely and applies
|
||||
// them via Raft.
|
||||
func (s *Server) planApply() {
|
||||
for {
|
||||
// Pull the next pending plan, exit if we are no longer leader
|
||||
pending, err := s.planQueue.Dequeue(0)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Evaluate the plan
|
||||
|
||||
// TODO: Apply the plan
|
||||
|
||||
// TODO: Prepare the response
|
||||
result := &structs.PlanResult{
|
||||
AllocIndex: 1000,
|
||||
}
|
||||
|
||||
// Respond to the plan
|
||||
pending.respond(result, nil)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user