-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-6443][Spark Submit]Could not submit app in standalone cluster mode when HA is enabled #5116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fa1fa80
submit app to HA cluster in standalone cluster mode
WangTaoTheTonic 60d97a4
rebase
WangTaoTheTonic 2b011c9
fix broken tests
WangTaoTheTonic 7a881b3
when one of masters is gone, we still can submit
WangTaoTheTonic 5d23958
refact some duplicated code, style and comments
WangTaoTheTonic e4f4ece
fix failed test
WangTaoTheTonic 979760c
rebase
WangTaoTheTonic 9d636be
per Andrew's comments
WangTaoTheTonic 35119a0
style and compile issues
WangTaoTheTonic 220cb3c
move connect exception inside
WangTaoTheTonic a41de0b
rebase
WangTaoTheTonic f4f972b
rebase...again
WangTaoTheTonic 76fd411
rebase
WangTaoTheTonic 2a28aab
based the newest change https://github.com/apache/spark/pull/5144
WangTaoTheTonic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
|
||
package org.apache.spark.deploy | ||
|
||
import scala.collection.mutable.HashSet | ||
import scala.concurrent._ | ||
|
||
import akka.actor._ | ||
|
@@ -31,21 +32,24 @@ import org.apache.spark.util.{ActorLogReceive, AkkaUtils, RpcUtils, Utils} | |
|
||
/** | ||
* Proxy that relays messages to the driver. | ||
* | ||
* We currently don't support retry if submission fails. In HA mode, client will submit request to | ||
* all masters and see which one could handle it. | ||
*/ | ||
private class ClientActor(driverArgs: ClientArguments, conf: SparkConf) | ||
extends Actor with ActorLogReceive with Logging { | ||
|
||
var masterActor: ActorSelection = _ | ||
private val masterActors = driverArgs.masters.map { m => | ||
context.actorSelection(Master.toAkkaUrl(m, AkkaUtils.protocol(context.system))) | ||
} | ||
private val lostMasters = new HashSet[Address] | ||
private var activeMasterActor: ActorSelection = null | ||
|
||
val timeout = RpcUtils.askTimeout(conf) | ||
|
||
override def preStart(): Unit = { | ||
masterActor = context.actorSelection( | ||
Master.toAkkaUrl(driverArgs.master, AkkaUtils.protocol(context.system))) | ||
|
||
context.system.eventStream.subscribe(self, classOf[RemotingLifecycleEvent]) | ||
|
||
println(s"Sending ${driverArgs.cmd} command to ${driverArgs.master}") | ||
|
||
driverArgs.cmd match { | ||
case "launch" => | ||
// TODO: We could add an env variable here and intercept it in `sc.addJar` that would | ||
|
@@ -79,11 +83,17 @@ private class ClientActor(driverArgs: ClientArguments, conf: SparkConf) | |
driverArgs.supervise, | ||
command) | ||
|
||
masterActor ! RequestSubmitDriver(driverDescription) | ||
// This assumes only one Master is active at a time | ||
for (masterActor <- masterActors) { | ||
masterActor ! RequestSubmitDriver(driverDescription) | ||
} | ||
|
||
case "kill" => | ||
val driverId = driverArgs.driverId | ||
masterActor ! RequestKillDriver(driverId) | ||
// This assumes only one Master is active at a time | ||
for (masterActor <- masterActors) { | ||
masterActor ! RequestKillDriver(driverId) | ||
} | ||
} | ||
} | ||
|
||
|
@@ -92,10 +102,9 @@ private class ClientActor(driverArgs: ClientArguments, conf: SparkConf) | |
println("... waiting before polling master for driver state") | ||
Thread.sleep(5000) | ||
println("... polling master for driver state") | ||
val statusFuture = (masterActor ? RequestDriverStatus(driverId))(timeout) | ||
val statusFuture = (activeMasterActor ? RequestDriverStatus(driverId))(timeout) | ||
.mapTo[DriverStatusResponse] | ||
val statusResponse = Await.result(statusFuture, timeout) | ||
|
||
statusResponse.found match { | ||
case false => | ||
println(s"ERROR: Cluster master did not recognize $driverId") | ||
|
@@ -122,20 +131,46 @@ private class ClientActor(driverArgs: ClientArguments, conf: SparkConf) | |
|
||
case SubmitDriverResponse(success, driverId, message) => | ||
println(message) | ||
if (success) pollAndReportStatus(driverId.get) else System.exit(-1) | ||
if (success) { | ||
activeMasterActor = context.actorSelection(sender.path) | ||
pollAndReportStatus(driverId.get) | ||
} else if (!Utils.responseFromBackup(message)) { | ||
System.exit(-1) | ||
} | ||
|
||
|
||
case KillDriverResponse(driverId, success, message) => | ||
println(message) | ||
if (success) pollAndReportStatus(driverId) else System.exit(-1) | ||
if (success) { | ||
activeMasterActor = context.actorSelection(sender.path) | ||
pollAndReportStatus(driverId) | ||
} else if (!Utils.responseFromBackup(message)) { | ||
System.exit(-1) | ||
} | ||
|
||
case DisassociatedEvent(_, remoteAddress, _) => | ||
println(s"Error connecting to master ${driverArgs.master} ($remoteAddress), exiting.") | ||
System.exit(-1) | ||
if (!lostMasters.contains(remoteAddress)) { | ||
println(s"Error connecting to master $remoteAddress.") | ||
lostMasters += remoteAddress | ||
// Note that this heuristic does not account for the fact that a Master can recover within | ||
// the lifetime of this client. Thus, once a Master is lost it is lost to us forever. This | ||
// is not currently a concern, however, because this client does not retry submissions. | ||
if (lostMasters.size >= masterActors.size) { | ||
println("No master is available, exiting.") | ||
System.exit(-1) | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is safe to do. A failed master can come back up, but according to this code it will still be in |
||
|
||
case AssociationErrorEvent(cause, _, remoteAddress, _, _) => | ||
println(s"Error connecting to master ${driverArgs.master} ($remoteAddress), exiting.") | ||
println(s"Cause was: $cause") | ||
System.exit(-1) | ||
if (!lostMasters.contains(remoteAddress)) { | ||
println(s"Error connecting to master ($remoteAddress).") | ||
println(s"Cause was: $cause") | ||
lostMasters += remoteAddress | ||
if (lostMasters.size >= masterActors.size) { | ||
println("No master is available, exiting.") | ||
System.exit(-1) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -163,7 +198,9 @@ object Client { | |
"driverClient", Utils.localHostName(), 0, conf, new SecurityManager(conf)) | ||
|
||
// Verify driverArgs.master is a valid url so that we can use it in ClientActor safely | ||
Master.toAkkaUrl(driverArgs.master, AkkaUtils.protocol(actorSystem)) | ||
for (m <- driverArgs.masters) { | ||
Master.toAkkaUrl(m, AkkaUtils.protocol(actorSystem)) | ||
} | ||
actorSystem.actorOf(Props(classOf[ClientActor], driverArgs, conf)) | ||
|
||
actorSystem.awaitTermination() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line needs a big comment: