Skip to content

Commit 62c5576

Browse files
committed
[SPARK-3375] spark on yarn container allocation issues
If yarn doesn't get the containers immediately it stops asking for them and the yarn application hangs with never getting any executors. The issue here is that we are sending the number of containers as 0 after we send the original one of X. on the yarn side this clears out the original request. For a ping we should just send empty asks. Author: Thomas Graves <[email protected]> Closes apache#2275 from tgravescs/SPARK-3375 and squashes the following commits: 74b6820 [Thomas Graves] send empty resource requests when we aren't asking for containers
1 parent 51b53a7 commit 62c5576

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
@@ -51,12 +51,13 @@ private[yarn] class YarnAllocationHandler(
5151
override protected def allocateContainers(count: Int): YarnAllocateResponse = {
5252
var resourceRequests: List[ResourceRequest] = null
5353

54-
// default.
55-
if (count <= 0 || preferredHostToCount.isEmpty) {
56-
logDebug("numExecutors: " + count + ", host preferences: " +
57-
preferredHostToCount.isEmpty)
58-
resourceRequests = List(createResourceRequest(
59-
AllocationType.ANY, null, count, YarnSparkHadoopUtil.RM_REQUEST_PRIORITY))
54+
logDebug("numExecutors: " + count)
55+
if (count <= 0) {
56+
resourceRequests = List()
57+
} else if (preferredHostToCount.isEmpty) {
58+
logDebug("host preferences is empty")
59+
resourceRequests = List(createResourceRequest(
60+
AllocationType.ANY, null, count, YarnSparkHadoopUtil.RM_REQUEST_PRIORITY))
6061
} else {
6162
// request for all hosts in preferred nodes and for numExecutors -
6263
// 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
@@ -88,9 +88,11 @@ private[yarn] class YarnAllocationHandler(
8888

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

0 commit comments

Comments
 (0)