-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
[SPARK-19750][UI][branch-2.1] Fix redirect issue from http to https #17083
Conversation
Change-Id: I5306a7553c230811dcada4d9c205b82b2af77c6e
Was this fixed otherwise in master, or did some other change make it obsolete? just trying to link this to whatever reason it's only a problem in 2.1, for the record. |
Due to the change of (#16625), the issue is obsolete. So it effects spark 2.1 and 2.0. |
Not sure why Jenkins test cannot be started automatically. |
@@ -378,7 +378,8 @@ private[spark] object JettyUtils extends Logging { | |||
server.getHandler().asInstanceOf[ContextHandlerCollection]) | |||
} | |||
|
|||
private def createRedirectHttpsHandler(securePort: Int, scheme: String): ContextHandler = { | |||
private def createRedirectHttpsHandler( | |||
httpsConnector: ServerConnector, scheme: String): ContextHandler = { |
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.
nit: one argument per line when using multiple lines.
But instead of changing this, why not pass the correct port from the caller in the first place?
@@ -267,8 +267,11 @@ class UISuite extends SparkFunSuite { | |||
s"$scheme://localhost:$port/test1/root", | |||
s"$scheme://localhost:$port/test2/root") | |||
urls.foreach { url => | |||
val rc = TestUtils.httpResponseCode(new URL(url)) | |||
assert(rc === expected, s"Unexpected status $rc for $url") | |||
val rc = TestUtils.httpResponseCodeAndURL(new URL(url)) |
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.
val (rc, redirectUrl) = ...
Test build #73498 has finished for PR 17083 at commit
|
Change-Id: I9d10be4fa9d6bc932422ba97574f561d3b0bb430
Test build #73551 has finished for PR 17083 at commit
|
Ping @vanzin , do you have any further comments? Thanks a lot. |
@@ -330,7 +330,7 @@ private[spark] object JettyUtils extends Logging { | |||
|
|||
// redirect the HTTP requests to HTTPS port | |||
httpConnector.setName(REDIRECT_CONNECTOR_NAME) | |||
collection.addHandler(createRedirectHttpsHandler(securePort, scheme)) | |||
collection.addHandler(createRedirectHttpsHandler(connector, scheme)) |
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.
So is there a reason why you didn't make this a single line change to pass the correct port?
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.
@vanzin , AFAIK in this code, at that time when we create a redirect handler, the https ServerConnector
hasn't yet started, so we couldn't get the real port from it, it will return -1 as we call getLocalPort
.
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.
Ah, good point. I guess I was thinking about the code in master which starts the connector right away.
Merging to 2.1 / 2.0. |
## What changes were proposed in this pull request? If spark ui port (4040) is not set, it will choose port number 0, this will make https port to also choose 0. And in Spark 2.1 code, it will use this https port (0) to do redirect, so when redirect triggered, it will point to a wrong url: like: ``` /tmp/temp$ wget http://172.27.25.134:55015 --2017-02-23 12:13:54-- http://172.27.25.134:55015/ Connecting to 172.27.25.134:55015... connected. HTTP request sent, awaiting response... 302 Found Location: https://172.27.25.134:0/ [following] --2017-02-23 12:13:54-- https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:13:55-- (try: 2) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:13:57-- (try: 3) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:14:00-- (try: 4) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. ``` So instead of using 0 to do redirect, we should pick a bound port instead. This issue only exists in Spark 2.1-, and can be reproduced in yarn cluster mode. ## How was this patch tested? Current redirect UT doesn't verify this issue, so extend current UT to do correct verification. Author: jerryshao <sshao@hortonworks.com> Closes #17083 from jerryshao/SPARK-19750.
@jerryshao I think you'll need to manually close the PR. |
## What changes were proposed in this pull request? If spark ui port (4040) is not set, it will choose port number 0, this will make https port to also choose 0. And in Spark 2.1 code, it will use this https port (0) to do redirect, so when redirect triggered, it will point to a wrong url: like: ``` /tmp/temp$ wget http://172.27.25.134:55015 --2017-02-23 12:13:54-- http://172.27.25.134:55015/ Connecting to 172.27.25.134:55015... connected. HTTP request sent, awaiting response... 302 Found Location: https://172.27.25.134:0/ [following] --2017-02-23 12:13:54-- https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:13:55-- (try: 2) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:13:57-- (try: 3) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. --2017-02-23 12:14:00-- (try: 4) https://172.27.25.134:0/ Connecting to 172.27.25.134:0... failed: Can't assign requested address. Retrying. ``` So instead of using 0 to do redirect, we should pick a bound port instead. This issue only exists in Spark 2.1-, and can be reproduced in yarn cluster mode. ## How was this patch tested? Current redirect UT doesn't verify this issue, so extend current UT to do correct verification. Author: jerryshao <sshao@hortonworks.com> Closes #17083 from jerryshao/SPARK-19750. (cherry picked from commit 3a7591a) Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
OK, Thanks @vanzin . |
What changes were proposed in this pull request?
If spark ui port (4040) is not set, it will choose port number 0, this will make https port to also choose 0. And in Spark 2.1 code, it will use this https port (0) to do redirect, so when redirect triggered, it will point to a wrong url:
like:
So instead of using 0 to do redirect, we should pick a bound port instead.
This issue only exists in Spark 2.1-, and can be reproduced in yarn cluster mode.
How was this patch tested?
Current redirect UT doesn't verify this issue, so extend current UT to do correct verification.