Skip to content

Commit

Permalink
scheduler: make version checks specific to region
Browse files Browse the repository at this point in the history
Disconnected clients handling is specific to a single region, so we don't want
to enforce that the version check across all of serf, just members in the same
region.
  • Loading branch information
tgross committed Oct 17, 2022
1 parent cd1c80c commit ad49454
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions nomad/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,11 @@ func (w *Worker) invokeScheduler(snap *state.StateSnapshot, eval *structs.Evalua
return nil
}

// ServersMeetMinimumVersion allows implementations of the Scheduler interface in
// RegionServersMeetMinimumVersion allows implementations of the Scheduler interface in
// other packages to perform server version checks without direct references to
// the Nomad server.
func (w *Worker) ServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool {
return ServersMeetMinimumVersion(w.srv.Members(), minVersion, checkFailedServers)
func (w *Worker) RegionServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool {
return RegionServersMeetMinimumVersion(w.srv.Members(), w.srv.Region(), minVersion, checkFailedServers)
}

// SubmitPlan is used to submit a plan for consideration. This allows
Expand Down
2 changes: 1 addition & 1 deletion scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ func (s *GenericScheduler) computeJobAllocs() error {
reconciler := NewAllocReconciler(s.logger,
genericAllocUpdateFn(s.ctx, s.stack, s.eval.ID),
s.batch, s.eval.JobID, s.job, s.deployment, allocs, tainted, s.eval.ID,
s.eval.Priority, s.planner.ServersMeetMinimumVersion(minVersionMaxClientDisconnect, true))
s.eval.Priority, s.planner.RegionServersMeetMinimumVersion(minVersionMaxClientDisconnect, true))

results := reconciler.Compute()
s.logger.Debug("reconciled current state with desired state", "results", log.Fmt("%#v", results))
Expand Down
9 changes: 5 additions & 4 deletions scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ type Planner interface {
// that on leader changes, the evaluation will be reblocked properly.
ReblockEval(*structs.Evaluation) error

// ServersMeetMinimumVersion returns whether the Nomad servers are at least on the
// given Nomad version. The checkFailedServers parameter specifies whether version
// for the failed servers should be verified.
ServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool
// RegionServersMeetMinimumVersion returns whether the Nomad servers in the
// worker's region are at least on the given Nomad version. The
// checkFailedServers parameter specifies whether version for the failed
// servers should be verified.
RegionServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool
}
2 changes: 1 addition & 1 deletion scheduler/scheduler_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (s *SystemScheduler) computeJobAllocs() error {

// Diff the required and existing allocations
diff := diffSystemAllocs(s.job, s.nodes, s.notReadyNodes, tainted, live, term,
s.planner.ServersMeetMinimumVersion(minVersionMaxClientDisconnect, true))
s.planner.RegionServersMeetMinimumVersion(minVersionMaxClientDisconnect, true))

s.logger.Debug("reconciled current state with desired state",
"place", len(diff.place), "update", len(diff.update),
Expand Down
4 changes: 2 additions & 2 deletions scheduler/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type RejectPlan struct {
Harness *Harness
}

func (r *RejectPlan) ServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool {
func (r *RejectPlan) RegionServersMeetMinimumVersion(minVersion *version.Version, checkFailedServers bool) bool {
return r.Harness.serversMeetMinimumVersion
}

Expand Down Expand Up @@ -250,7 +250,7 @@ func (h *Harness) ReblockEval(eval *structs.Evaluation) error {
return nil
}

func (h *Harness) ServersMeetMinimumVersion(_ *version.Version, _ bool) bool {
func (h *Harness) RegionServersMeetMinimumVersion(_ *version.Version, _ bool) bool {
return h.serversMeetMinimumVersion
}

Expand Down

0 comments on commit ad49454

Please sign in to comment.