Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,7 @@ const (
NodeStatusReady = "ready"
NodeStatusDown = "down"
NodeStatusDisconnected = "disconnected"
NodeStatusNoRecord = "no_record"
)

// ShouldDrainNode checks if a given node status should trigger an
Expand Down
2 changes: 1 addition & 1 deletion scheduler/generic_sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (s *GenericScheduler) computeJobAllocs() error {
}

// Determine the tainted nodes containing job allocs
tainted, err := taintedNodes(s.state, allocs)
tainted, err := getTaintedNodes(s.state, allocs)
if err != nil {
return fmt.Errorf("failed to get tainted nodes for job '%s': %v",
s.eval.JobID, err)
Expand Down
2 changes: 1 addition & 1 deletion scheduler/reconciler/reconcile_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5070,7 +5070,7 @@ func TestReconciler_TaintedNode_RollingUpgrade(t *testing.T) {

// Tests the reconciler handles a failed deployment with allocs on tainted
// nodes
func TestReconciler_FailedDeployment_TaintedNodes(t *testing.T) {
func TestReconciler_FailedDeployment_GetTaintedNodes(t *testing.T) {
ci.Parallel(t)

job := mock.Job()
Expand Down
2 changes: 1 addition & 1 deletion scheduler/scheduler_sysbatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (s *SysBatchScheduler) computeJobAllocs() error {
}

// Determine the tainted nodes containing job allocs
tainted, err := taintedNodes(s.state, allocs)
tainted, err := getTaintedNodes(s.state, allocs)
if err != nil {
return fmt.Errorf("failed to get tainted nodes for job '%s': %v", s.eval.JobID, err)
}
Expand Down
2 changes: 1 addition & 1 deletion scheduler/scheduler_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (s *SystemScheduler) computeJobAllocs() error {
}

// Determine the tainted nodes containing job allocs
tainted, err := taintedNodes(s.state, allocs)
tainted, err := getTaintedNodes(s.state, allocs)
if err != nil {
return fmt.Errorf("failed to get tainted nodes for job '%s': %v", s.eval.JobID, err)
}
Expand Down
14 changes: 9 additions & 5 deletions scheduler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ func progressMade(result *structs.PlanResult) bool {
len(result.DeploymentUpdates) != 0)
}

// taintedNodes is used to scan the allocations and then check if the
// getTaintedNodes is used to scan the allocations and then check if the
// underlying nodes are tainted, and should force a migration of the allocation,
// or if the underlying nodes are disconnected, and should be used to calculate
// the reconnect timeout of its allocations. All the nodes returned in the map are tainted.
func taintedNodes(state sstructs.State, allocs []*structs.Allocation) (map[string]*structs.Node, error) {
func getTaintedNodes(state sstructs.State, allocs []*structs.Allocation) (map[string]*structs.Node, error) {
out := make(map[string]*structs.Node)

for _, alloc := range allocs {
if _, ok := out[alloc.NodeID]; ok {
continue
Expand All @@ -115,16 +116,19 @@ func taintedNodes(state sstructs.State, allocs []*structs.Allocation) (map[strin

// If the node does not exist, we should migrate
if node == nil {
out[alloc.NodeID] = nil
out[alloc.NodeID] = &structs.Node{
Status: structs.NodeStatusNoRecord,
}
continue
}

if structs.ShouldDrainNode(node.Status) || node.DrainStrategy != nil {
out[alloc.NodeID] = node
continue
}

// Disconnected nodes are included in the tainted set so that their
// disconnect.lost_after configuration can be included in the
// timeout calculation.
// disconnect flow for allocs can be triggered.
if node.Status == structs.NodeStatusDisconnected {
out[alloc.NodeID] = node
}
Expand Down
4 changes: 2 additions & 2 deletions scheduler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func TestRetryMax(t *testing.T) {
must.Eq(t, 1, calls)
}

func TestTaintedNodes(t *testing.T) {
func TestGetTaintedNodes(t *testing.T) {
ci.Parallel(t)

state := state.TestStateStore(t)
Expand All @@ -180,7 +180,7 @@ func TestTaintedNodes(t *testing.T) {
{NodeID: node4.ID},
{NodeID: "12345678-abcd-efab-cdef-123456789abc"},
}
tainted, err := taintedNodes(state, allocs)
tainted, err := getTaintedNodes(state, allocs)
must.NoError(t, err)
must.Eq(t, 3, len(tainted))
must.MapNotContainsKey(t, tainted, node1.ID)
Expand Down
Loading