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

Detect network mode change #7414

Merged
merged 1 commit into from Mar 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions scheduler/util.go
Expand Up @@ -437,6 +437,10 @@ func networkUpdated(netA, netB []*structs.NetworkResource) bool {
an := netA[idx]
bn := netB[idx]

if an.Mode != bn.Mode {
return true
}

if an.MBits != bn.MBits {
return true
}
Expand Down
14 changes: 14 additions & 0 deletions scheduler/util_test.go
Expand Up @@ -675,6 +675,20 @@ func TestTasksUpdated(t *testing.T) {
j18 := mock.Job()
j18.Meta["j18_test"] = "roll_baby_roll"
require.True(t, tasksUpdated(j1, j18, name))

// Change network mode
j19 := mock.Job()
j19.TaskGroups[0].Networks = j19.TaskGroups[0].Tasks[0].Resources.Networks
j19.TaskGroups[0].Tasks[0].Resources.Networks = nil

j20 := mock.Job()
j20.TaskGroups[0].Networks = j20.TaskGroups[0].Tasks[0].Resources.Networks
j20.TaskGroups[0].Tasks[0].Resources.Networks = nil

require.False(t, tasksUpdated(j19, j20, name))

j20.TaskGroups[0].Networks[0].Mode = "bridge"
require.True(t, tasksUpdated(j19, j20, name))
}

func TestEvictAndPlace_LimitLessThanAllocs(t *testing.T) {
Expand Down