Skip to content

Commit

Permalink
dont evaluate existing reservations against new ports (#2928)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvish authored Feb 16, 2019
1 parent c9ea49c commit c0cd652
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,19 @@ private Optional<ResourceLabels> findMatchingPortSpec(
PortSpec portSpec = (PortSpec) resourceSpec;
if (portSpec.getPort() == 0) {
// For dynamic ports, we need to detect the port value that we had selected.
return taskPortFinder.getPriorPort(portSpec)
.filter(priorTaskPort -> RangeUtils.isInAny(ranges.getRangeList(), priorTaskPort))
.map(ignored -> new ResourceLabels(
resourceSpec,
resourceId.get(),
ResourceMapperUtils.getNamespaceLabel(
ResourceUtils.getNamespace(taskResource),
resourceNamespace)));
Optional<Long> priorPort = taskPortFinder.getPriorPort(portSpec);
if (!priorPort.isPresent()) {
//this is a new portSpec and will never match a previously reserved taskResource
continue;
}
return priorPort
.filter(priorTaskPort -> RangeUtils.isInAny(ranges.getRangeList(), priorTaskPort))
.map(ignored -> new ResourceLabels(
resourceSpec,
resourceId.get(),
ResourceMapperUtils.getNamespaceLabel(
ResourceUtils.getNamespace(taskResource),
resourceNamespace)));
} else if (RangeUtils.isInAny(ranges.getRangeList(), portSpec.getPort())) {
// For fixed ports, we can just check for a resource whose ranges include that port.
return Optional.of(new ResourceLabels(
Expand Down

0 comments on commit c0cd652

Please sign in to comment.