From c0cd6528b7f26276f25a712a92996e9cba204611 Mon Sep 17 00:00:00 2001 From: Karan Date: Fri, 15 Feb 2019 20:36:31 -0800 Subject: [PATCH] dont evaluate existing reservations against new ports (#2928) --- .../offer/evaluate/TaskResourceMapper.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/sdk/scheduler/src/main/java/com/mesosphere/sdk/offer/evaluate/TaskResourceMapper.java b/sdk/scheduler/src/main/java/com/mesosphere/sdk/offer/evaluate/TaskResourceMapper.java index f4efd5edb19..b751abb971b 100644 --- a/sdk/scheduler/src/main/java/com/mesosphere/sdk/offer/evaluate/TaskResourceMapper.java +++ b/sdk/scheduler/src/main/java/com/mesosphere/sdk/offer/evaluate/TaskResourceMapper.java @@ -158,14 +158,19 @@ private Optional 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 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(