diff --git a/client/allocrunner/network_manager_linux.go b/client/allocrunner/network_manager_linux.go index cc212aa4a..a354eb541 100644 --- a/client/allocrunner/network_manager_linux.go +++ b/client/allocrunner/network_manager_linux.go @@ -123,6 +123,12 @@ func netModeToIsolationMode(netMode string) drivers.NetIsolationMode { func newNetworkConfigurator(alloc *structs.Allocation, config *clientconfig.Config) NetworkConfigurator { tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup) + + // Check if network stanza is given + if len(tg.Networks) == 0 { + return &hostNetworkConfigurator{} + } + switch strings.ToLower(tg.Networks[0].Mode) { case "bridge": return newBridgeNetworkConfigurator(context.Background(), config.BridgeNetworkName, config.BridgeNetworkAllocSubnet, config.CNIPath) diff --git a/scheduler/generic_sched.go b/scheduler/generic_sched.go index 0dbda31c5..15322d832 100644 --- a/scheduler/generic_sched.go +++ b/scheduler/generic_sched.go @@ -484,8 +484,10 @@ func (s *GenericScheduler) computePlacements(destructive, place []placementResul // Set fields based on if we found an allocation option if option != nil { resources := &structs.AllocatedResources{ - Tasks: option.TaskResources, - Shared: *option.GroupResources, + Tasks: option.TaskResources, + } + if option.AllocResources != nil { + resources.Shared = *option.AllocResources } // Create an allocation for this diff --git a/scheduler/rank.go b/scheduler/rank.go index b151f1fca..d90d74bd4 100644 --- a/scheduler/rank.go +++ b/scheduler/rank.go @@ -21,7 +21,7 @@ type RankedNode struct { FinalScore float64 Scores []float64 TaskResources map[string]*structs.AllocatedTaskResources - GroupResources *structs.AllocatedSharedResources + AllocResources *structs.AllocatedSharedResources // Allocs is used to cache the proposed allocations on the // node. This can be shared between iterators that require it. @@ -271,7 +271,7 @@ OUTER: // Update the network ask to the offer total.Shared.Networks = []*structs.NetworkResource{offer} - option.GroupResources = &structs.AllocatedSharedResources{ + option.AllocResources = &structs.AllocatedSharedResources{ Networks: []*structs.NetworkResource{offer}, DiskMB: int64(iter.taskGroup.EphemeralDisk.SizeMB), } diff --git a/scheduler/util.go b/scheduler/util.go index f21575d36..ce4509ffa 100644 --- a/scheduler/util.go +++ b/scheduler/util.go @@ -835,9 +835,12 @@ func genericAllocUpdateFn(ctx Context, stack Stack, evalID string) allocUpdateTy newAlloc.Job = nil // Use the Job in the Plan newAlloc.Resources = nil // Computed in Plan Apply newAlloc.AllocatedResources = &structs.AllocatedResources{ - Tasks: option.TaskResources, - Shared: *option.GroupResources, + Tasks: option.TaskResources, } + if option.AllocResources != nil { + newAlloc.AllocatedResources.Shared = *option.AllocResources + } + // 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