Skip to content

Commit 74b6820

Browse files
committed
send empty resource requests when we aren't asking for containers
1 parent 00362da commit 74b6820

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocationHandler.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ private[yarn] class YarnAllocationHandler(
5050
override protected def allocateContainers(count: Int): YarnAllocateResponse = {
5151
var resourceRequests: List[ResourceRequest] = null
5252

53-
// default.
54-
if (count <= 0 || preferredHostToCount.isEmpty) {
55-
logDebug("numExecutors: " + count + ", host preferences: " +
56-
preferredHostToCount.isEmpty)
57-
resourceRequests = List(createResourceRequest(
58-
AllocationType.ANY, null, count, YarnSparkHadoopUtil.RM_REQUEST_PRIORITY))
53+
logDebug("numExecutors: " + count)
54+
if (count <= 0) {
55+
resourceRequests = List()
56+
} else if (preferredHostToCount.isEmpty) {
57+
logDebug("host preferences is empty")
58+
resourceRequests = List(createResourceRequest(
59+
AllocationType.ANY, null, count, YarnSparkHadoopUtil.RM_REQUEST_PRIORITY))
5960
} else {
6061
// request for all hosts in preferred nodes and for numExecutors -
6162
// candidates.size, request by default allocation policy.

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocationHandler.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ private[yarn] class YarnAllocationHandler(
8787

8888
private def addResourceRequests(numExecutors: Int) {
8989
val containerRequests: List[ContainerRequest] =
90-
if (numExecutors <= 0 || preferredHostToCount.isEmpty) {
91-
logDebug("numExecutors: " + numExecutors + ", host preferences: " +
92-
preferredHostToCount.isEmpty)
90+
if (numExecutors <= 0) {
91+
logDebug("numExecutors: " + numExecutors)
92+
List()
93+
} else if (preferredHostToCount.isEmpty) {
94+
logDebug("host preferences is empty")
9395
createResourceRequests(
9496
AllocationType.ANY,
9597
resource = null,

0 commit comments

Comments
 (0)