From 95ae01a9f470209300bf15ed88ce230bb4e2aad9 Mon Sep 17 00:00:00 2001 From: Chris Baker <1675087+cgbaker@users.noreply.github.com> Date: Thu, 7 Nov 2019 17:51:15 +0000 Subject: [PATCH] the scheduler checks whether task changes require a restart, this needed to be updated to consider devices --- scheduler/util.go | 2 ++ scheduler/util_test.go | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/scheduler/util.go b/scheduler/util.go index 13fcc11e6..37a5b729d 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -401,6 +401,8 @@ func tasksUpdated(jobA, jobB *structs.Job, taskGroup string) bool { return true } else if ar.MemoryMB != br.MemoryMB { return true + } else if !ar.Devices.Equals(&br.Devices) { + return true } } return false diff --git a/scheduler/util_test.go b/scheduler/util_test.go index 08f5812aa..0e8962624 100644 --- a/scheduler/util_test.go +++ b/scheduler/util_test.go @@ -527,6 +527,24 @@ func TestTasksUpdated(t *testing.T) { t.Fatalf("bad") } + j11d1 := mock.Job() + j11d1.TaskGroups[0].Tasks[0].Resources.Devices = structs.ResourceDevices{ + &structs.RequestedDevice{ + Name: "gpu", + Count: 1, + }, + } + j11d2 := mock.Job() + j11d2.TaskGroups[0].Tasks[0].Resources.Devices = structs.ResourceDevices{ + &structs.RequestedDevice{ + Name: "gpu", + Count: 2, + }, + } + if !tasksUpdated(j11d1, j11d2, name) { + t.Fatalf("bad") + } + j12 := mock.Job() j12.TaskGroups[0].Tasks[0].Resources.Networks[0].MBits = 100 if !tasksUpdated(j1, j12, name) {