From 9859b83ab04d39f977660dd0b3f77a3c5741141c Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Wed, 23 Oct 2019 15:23:16 -0700 Subject: [PATCH] core: fix panic when AllocatedResources is nil Potential fix for #6540 --- scheduler/util.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scheduler/util.go b/scheduler/util.go index 0d226171e3e6..fdcc10c5694e 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -838,13 +838,16 @@ func genericAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateTy Tasks: option.TaskResources, Shared: structs.AllocatedSharedResources{ DiskMB: int64(newTG.EphemeralDisk.SizeMB), - // Since this is an inplace update, we should copy network - // information from the original alloc. This is similar to - // how we copy network info for task level networks above. - Networks: existing.AllocatedResources.Shared.Networks, }, } + // Since this is an inplace update, we should copy network + // information from the original alloc. This is similar to how + // we copy network info for task level networks above. + if existing.AllocatedResources != nil { + newAlloc.AllocatedResources.Shared.Networks = existing.AllocatedResources.Shared.Networks + } + // Use metrics from existing alloc for in place upgrade // This is because if the inplace upgrade succeeded, any scoring metadata from // when it first went through the scheduler should still be preserved. Using scoring