From 99e5318173f4918fa0f028eeed07415ffa37645c Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 18 Dec 2024 17:06:51 -0500 Subject: [PATCH] address comments from code review --- scheduler/feasible.go | 12 +++++++----- scheduler/feasible_test.go | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scheduler/feasible.go b/scheduler/feasible.go index fded9ebd73..fa1800b2ae 100644 --- a/scheduler/feasible.go +++ b/scheduler/feasible.go @@ -290,14 +290,16 @@ func (h *HostVolumeChecker) hostVolumeIsAvailable( // examine all proposed allocs on the node, including those that might // not have yet been persisted. they have nil pointers to their Job, so // we have to go back to the state store to get them - seen := map[structs.NamespacedID]struct{}{} + seen := map[string]struct{}{} for _, alloc := range proposed { - if _, ok := seen[alloc.JobNamespacedID()]; ok { - // all allocs for the same job will have the same read-only flag - // and capabilities, so we only need to check a given job once + uniqueGroup := alloc.JobNamespacedID().String() + alloc.TaskGroup + if _, ok := seen[uniqueGroup]; ok { + // all allocs for the same group will have the same read-only + // flag and capabilities, so we only need to check a given group + // once continue } - seen[alloc.JobNamespacedID()] = struct{}{} + seen[uniqueGroup] = struct{}{} job, err := h.ctx.State().JobByID(nil, alloc.Namespace, alloc.JobID) if err != nil { return false diff --git a/scheduler/feasible_test.go b/scheduler/feasible_test.go index d37ec5c416..18a8153e83 100644 --- a/scheduler/feasible_test.go +++ b/scheduler/feasible_test.go @@ -477,7 +477,7 @@ func TestHostVolumeChecker_Sticky(t *testing.T) { } // TestDynamicHostVolumeIsAvailable provides fine-grained coverage of the -// dynamicHostVolumeIsAvailable function +// hostVolumeIsAvailable method func TestDynamicHostVolumeIsAvailable(t *testing.T) { store, ctx := testContext(t)