Skip to content

Commit

Permalink
core: merge reserved_ports into host_networks
Browse files Browse the repository at this point in the history
Fixes #13505

WIP
  • Loading branch information
schmichael committed Jul 8, 2022
1 parent 545ee56 commit d1b652c
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 139 deletions.
11 changes: 9 additions & 2 deletions nomad/structs/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ func AllocsFit(node *Node, allocs []*Allocation, netIdx *NetworkIndex, checkDevi
netIdx = NewNetworkIndex()
defer netIdx.Release()

if collision, reason := netIdx.SetNode(node); collision {
return false, fmt.Sprintf("reserved node port collision: %v", reason), used, nil
if err := netIdx.SetNode(node); err != nil {
// To maintain backward compatibility with when SetNode
// returned collision+reason like AddAllocs, return
// this as a reason instead of an error.
return false, fmt.Sprintf("reserved node port collision: %v", err), used, nil
}
if collision, reason := netIdx.AddAllocs(allocs); collision {
return false, fmt.Sprintf("reserved alloc port collision: %v", reason), used, nil
Expand Down Expand Up @@ -530,6 +533,10 @@ func ParsePortRanges(spec string) ([]uint64, error) {
if err != nil {
return nil, err
}

if port > MaxValidPort {
return nil, fmt.Errorf("port must be < %d but found %d", MaxValidPort, port)
}
ports[port] = struct{}{}
}
case 2:
Expand Down
Loading

0 comments on commit d1b652c

Please sign in to comment.