diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java index 776e512..a9806e3 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacityScheduler.java @@ -2696,11 +2696,15 @@ public boolean attemptAllocationOnNode(SchedulerApplicationAttempt appAttempt, ((RMContainerImpl)rmContainer).setAllocationTags( new HashSet<>(schedulingRequest.getAllocationTags())); - allocated = new ContainerAllocationProposal<>( - getSchedulerContainer(rmContainer, true), - null, null, NodeType.NODE_LOCAL, NodeType.NODE_LOCAL, - SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, - resource); + SchedulerContainer + schedulerContainer = getSchedulerContainer(rmContainer, true); + if (schedulerContainer == null) { + allocated = null; + } else { + allocated = new ContainerAllocationProposal<>(schedulerContainer, + null, null, NodeType.NODE_LOCAL, NodeType.NODE_LOCAL, + SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, resource); + } } if (null != allocated) { @@ -2730,16 +2734,27 @@ public boolean attemptAllocationOnNode(SchedulerApplicationAttempt appAttempt, csAssignment.getAssignmentInformation().getAllocationDetails(); if (!allocations.isEmpty()) { RMContainer rmContainer = allocations.get(0).rmContainer; - allocated = new ContainerAllocationProposal<>( - getSchedulerContainer(rmContainer, true), - getSchedulerContainersToRelease(csAssignment), - getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), - false), csAssignment.getType(), - csAssignment.getRequestLocalityType(), - csAssignment.getSchedulingMode() != null ? - csAssignment.getSchedulingMode() : - SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, - csAssignment.getResource()); + SchedulerContainer + schedulerContainer = getSchedulerContainer(rmContainer, true); + if (schedulerContainer == null) { + allocated = null; + // Decrease unconfirmed resource if app is alive + FiCaSchedulerApp app = getApplicationAttempt( + rmContainer.getApplicationAttemptId()); + if (app != null) { + app.decUnconfirmedRes(rmContainer.getAllocatedResource()); + } + } else { + allocated = new ContainerAllocationProposal<>(schedulerContainer, + getSchedulerContainersToRelease(csAssignment), + getSchedulerContainer( + csAssignment.getFulfilledReservedContainer(), false), + csAssignment.getType(), csAssignment.getRequestLocalityType(), + csAssignment.getSchedulingMode() != null ? + csAssignment.getSchedulingMode() : + SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, + csAssignment.getResource()); + } } // Reserved something @@ -2747,16 +2762,21 @@ public boolean attemptAllocationOnNode(SchedulerApplicationAttempt appAttempt, csAssignment.getAssignmentInformation().getReservationDetails(); if (!reservation.isEmpty()) { RMContainer rmContainer = reservation.get(0).rmContainer; - reserved = new ContainerAllocationProposal<>( - getSchedulerContainer(rmContainer, false), - getSchedulerContainersToRelease(csAssignment), - getSchedulerContainer(csAssignment.getFulfilledReservedContainer(), - false), csAssignment.getType(), - csAssignment.getRequestLocalityType(), - csAssignment.getSchedulingMode() != null ? - csAssignment.getSchedulingMode() : - SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, - csAssignment.getResource()); + SchedulerContainer + schedulerContainer = getSchedulerContainer(rmContainer, false); + if (schedulerContainer == null) { + reserved = null; + } else { + reserved = new ContainerAllocationProposal<>(schedulerContainer, + getSchedulerContainersToRelease(csAssignment), + getSchedulerContainer( + csAssignment.getFulfilledReservedContainer(), false), + csAssignment.getType(), csAssignment.getRequestLocalityType(), + csAssignment.getSchedulingMode() != null ? + csAssignment.getSchedulingMode() : + SchedulingMode.RESPECT_PARTITION_EXCLUSIVITY, + csAssignment.getResource()); + } } }