Merge pull request #7414 from hashicorp/b-network-mode-change

Detect network mode change
This commit is contained in:
Mahmood Ali 2020-03-24 09:46:40 -04:00 committed by GitHub
commit 6ddf3d1742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -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
}

View File

@ -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) {