[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-03-02 Thread jerryshao
Github user jerryshao closed the pull request at:

https://github.com/apache/spark/pull/17083


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-03-02 Thread vanzin
Github user vanzin commented on a diff in the pull request:

https://github.com/apache/spark/pull/17083#discussion_r104070712
  
--- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
@@ -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))
--- End diff --

Ah, good point. I guess I was thinking about the code in master which 
starts the connector right away.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-03-02 Thread jerryshao
Github user jerryshao commented on a diff in the pull request:

https://github.com/apache/spark/pull/17083#discussion_r104064675
  
--- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
@@ -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))
--- End diff --

@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`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-03-02 Thread vanzin
Github user vanzin commented on a diff in the pull request:

https://github.com/apache/spark/pull/17083#discussion_r103997560
  
--- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
@@ -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))
--- End diff --

So is there a reason why you didn't make this a single line change to pass 
the correct port?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-02-27 Thread vanzin
Github user vanzin commented on a diff in the pull request:

https://github.com/apache/spark/pull/17083#discussion_r103278713
  
--- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
@@ -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 = {
--- End diff --

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?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-02-27 Thread vanzin
Github user vanzin commented on a diff in the pull request:

https://github.com/apache/spark/pull/17083#discussion_r103279006
  
--- Diff: core/src/test/scala/org/apache/spark/ui/UISuite.scala ---
@@ -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))
--- End diff --

`val (rc, redirectUrl) = ...`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] spark pull request #17083: [SPARK-19750][UI][branch-2.1] Fix redirect issue ...

2017-02-27 Thread jerryshao
GitHub user jerryshao opened a pull request:

https://github.com/apache/spark/pull/17083

[SPARK-19750][UI][branch-2.1] Fix redirect issue from http to https

## What changes were proposed in this pull request?

If spark ui port (4040) is not set, it will choose port number 0, and this 
will make https port to also choose 0. And in the current Spark 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.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/jerryshao/apache-spark SPARK-19750

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/17083.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #17083


commit 5408005912c1e369cbf3d77ea490b88f621ee047
Author: jerryshao 
Date:   2017-02-27T10:36:45Z

Fix redirect issue for https

Change-Id: I5306a7553c230811dcada4d9c205b82b2af77c6e




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org