Skip to content

[SPARK-12399] Display correct error message when accessing REST API with an unknown app Id #10352

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
wants to merge 2 commits into from

Conversation

carsonwang
Copy link
Contributor

I got an exception when accessing the below REST API with an unknown application Id.
http://<server-url>:18080/api/v1/applications/xxx/jobs
Instead of an exception, I expect an error message "no such app: xxx" which is a similar error message when I access /api/v1/applications/xxx

org.spark-project.guava.util.concurrent.UncheckedExecutionException: java.util.NoSuchElementException: no app with key xxx
    at org.spark-project.guava.cache.LocalCache$Segment.get(LocalCache.java:2263)
    at org.spark-project.guava.cache.LocalCache.get(LocalCache.java:4000)
    at org.spark-project.guava.cache.LocalCache.getOrLoad(LocalCache.java:4004)
    at org.spark-project.guava.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
    at org.apache.spark.deploy.history.HistoryServer.getSparkUI(HistoryServer.scala:116)
    at org.apache.spark.status.api.v1.UIRoot$class.withSparkUI(ApiRootResource.scala:226)
    at org.apache.spark.deploy.history.HistoryServer.withSparkUI(HistoryServer.scala:46)
    at org.apache.spark.status.api.v1.ApiRootResource.getJobs(ApiRootResource.scala:66)

val ui = appCache.get(appKey)
Some(ui)
} catch {
case e: Exception => e.getCause() match {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case NonFatal(e)

@andrewor14
Copy link
Contributor

@vanzin

@SparkQA
Copy link

SparkQA commented Dec 17, 2015

Test build #47915 has finished for PR 10352 at commit e926120.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):\n * class CrossValidator(Estimator, HasSeed):\n

@carsonwang
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Dec 18, 2015

Test build #47971 has finished for PR 10352 at commit e926120.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@carsonwang
Copy link
Contributor Author

retest this please

@SparkQA
Copy link

SparkQA commented Dec 18, 2015

Test build #47990 has finished for PR 10352 at commit e926120.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@@ -115,7 +117,17 @@ class HistoryServer(
}

def getSparkUI(appKey: String): Option[SparkUI] = {
Option(appCache.get(appKey))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a better fix to do appCache.getIfPresent here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appCache.getIfPresent returns null if there is no cached value for the appKey. But appCache.get will try to obtain that value from a CacheLoader, cache it and return it. So I think we still need use appCache.get here and handle the exception.

@vanzin
Copy link
Contributor

vanzin commented Dec 30, 2015

LGTM, merging to master and 1.6. Thanks!

asfgit pushed a commit that referenced this pull request Dec 30, 2015
…ith an unknown app Id

I got an exception when accessing the below REST API with an unknown application Id.
`http://<server-url>:18080/api/v1/applications/xxx/jobs`
Instead of an exception, I expect an error message "no such app: xxx" which is a similar error message when I access `/api/v1/applications/xxx`
```
org.spark-project.guava.util.concurrent.UncheckedExecutionException: java.util.NoSuchElementException: no app with key xxx
	at org.spark-project.guava.cache.LocalCache$Segment.get(LocalCache.java:2263)
	at org.spark-project.guava.cache.LocalCache.get(LocalCache.java:4000)
	at org.spark-project.guava.cache.LocalCache.getOrLoad(LocalCache.java:4004)
	at org.spark-project.guava.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4874)
	at org.apache.spark.deploy.history.HistoryServer.getSparkUI(HistoryServer.scala:116)
	at org.apache.spark.status.api.v1.UIRoot$class.withSparkUI(ApiRootResource.scala:226)
	at org.apache.spark.deploy.history.HistoryServer.withSparkUI(HistoryServer.scala:46)
	at org.apache.spark.status.api.v1.ApiRootResource.getJobs(ApiRootResource.scala:66)
```

Author: Carson Wang <[email protected]>

Closes #10352 from carsonwang/unknownAppFix.

(cherry picked from commit b244297)
Signed-off-by: Marcelo Vanzin <[email protected]>
@asfgit asfgit closed this in b244297 Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants