fix failing tests

This commit is contained in:
Nick Ethier
2019-06-18 00:55:43 -04:00
parent 4aefe5654d
commit e910fdbb32
4 changed files with 17 additions and 6 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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),
}

View File

@@ -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