Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduler: do network feasibility checking for system jobs #8256

Merged
merged 2 commits into from
Jun 24, 2020
Merged
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
6 changes: 5 additions & 1 deletion scheduler/feasible.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ func (c *NetworkChecker) hasNetwork(option *structs.Node) bool {
}

for _, nw := range option.NodeResources.Networks {
if nw.Mode == c.networkMode {
mode := nw.Mode
if mode == "" {
mode = "host"
}
if mode == c.networkMode {
return true
}
}
Expand Down
10 changes: 9 additions & 1 deletion scheduler/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ type SystemStack struct {
taskGroupDevices *DeviceChecker
taskGroupHostVolumes *HostVolumeChecker
taskGroupCSIVolumes *CSIVolumeChecker
taskGroupNetwork *NetworkChecker

distinctPropertyConstraint *DistinctPropertyIterator
binPack *BinPackIterator
Expand Down Expand Up @@ -220,14 +221,18 @@ func NewSystemStack(ctx Context) *SystemStack {
// Filter on task group devices
s.taskGroupDevices = NewDeviceChecker(ctx)

// Filter on available client networks
s.taskGroupNetwork = NewNetworkChecker(ctx)

// Create the feasibility wrapper which wraps all feasibility checks in
// which feasibility checking can be skipped if the computed node class has
// previously been marked as eligible or ineligible. Generally this will be
// checks that only needs to examine the single node to determine feasibility.
jobs := []FeasibilityChecker{s.jobConstraint}
tgs := []FeasibilityChecker{s.taskGroupDrivers, s.taskGroupConstraint,
s.taskGroupHostVolumes,
s.taskGroupDevices}
s.taskGroupDevices,
s.taskGroupNetwork}
avail := []FeasibilityChecker{s.taskGroupCSIVolumes}
s.wrappedChecks = NewFeasibilityWrapper(ctx, s.quota, jobs, tgs, avail)

Expand Down Expand Up @@ -285,6 +290,9 @@ func (s *SystemStack) Select(tg *structs.TaskGroup, options *SelectOptions) *Ran
s.taskGroupDevices.SetTaskGroup(tg)
s.taskGroupHostVolumes.SetVolumes(tg.Volumes)
s.taskGroupCSIVolumes.SetVolumes(tg.Volumes)
if len(tg.Networks) > 0 {
s.taskGroupNetwork.SetNetwork(tg.Networks[0])
}
s.wrappedChecks.SetTaskGroup(tg.Name)
s.distinctPropertyConstraint.SetTaskGroup(tg)
s.binPack.SetTaskGroup(tg)
Expand Down
13 changes: 13 additions & 0 deletions scheduler/system_sched_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,19 @@ func TestSystemSched_Preemption(t *testing.T) {
MBits: 1000,
},
},
NodeNetworks: []*structs.NodeNetworkResource{
{
Mode: "host",
Device: "eth0",
Addresses: []structs.NodeNetworkAddress{
{
Family: structs.NodeNetworkAF_IPv4,
Alias: "default",
Address: "192.168.0.100",
},
},
},
},
}
require.NoError(t, h.State.UpsertNode(h.NextIndex(), node))
nodes = append(nodes, node)
Expand Down