Skip to content

Commit

Permalink
Merge pull request #7414 from hashicorp/b-network-mode-change
Browse files Browse the repository at this point in the history
Detect network mode change
  • Loading branch information
Mahmood Ali committed Mar 24, 2020
2 parents 259311e + 82cb13a commit 08e5a90
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scheduler/util.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 08e5a90

Please sign in to comment.