From 9568553d7e8a43ff19145e3a2dc3893f4bbe5b96 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Sat, 21 Mar 2020 16:51:10 -0400 Subject: [PATCH] Detect network mode change Mark job as updated if network mode changed. --- scheduler/util.go | 4 ++++ scheduler/util_test.go | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/scheduler/util.go b/scheduler/util.go index d93b0e503..71032d9af 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -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 } diff --git a/scheduler/util_test.go b/scheduler/util_test.go index 55b67d9bd..56d2d2e6d 100644 --- a/scheduler/util_test.go +++ b/scheduler/util_test.go @@ -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) {