Skip to content

Conversation

@SaurabhChawla100
Copy link
Contributor

@SaurabhChawla100 SaurabhChawla100 commented Jun 9, 2020

What changes were proposed in this pull request?

After SPARK-31632 SparkException is thrown from def applicationInfo
def applicationInfo(): v1.ApplicationInfo = { try { // The ApplicationInfo may not be available when Spark is starting up. store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info } catch { case _: NoSuchElementException => throw new SparkException("Failed to get the application information. " + "If you are starting up Spark, please wait a while until it's ready.") } }

Where as the caller for this method def getSparkUser in Spark UI is not handling SparkException in the catch

def getSparkUser: String = { try { Option(store.applicationInfo().attempts.head.sparkUser) .orElse(store.environmentInfo().systemProperties.toMap.get("user.name")) .getOrElse("<unknown>") } catch { case _: NoSuchElementException => "<unknown>" } }

So On using this method (getSparkUser )we can get the application erred out.

As the part of this PR we will replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore

Why are the changes needed?

On invoking the method getSparkUser, we can get the SparkException on calling store.applicationInfo(). And this is not handled in the catch block and getSparkUser will error out in this scenario

Does this PR introduce any user-facing change?

No

How was this patch tested?

Done the manual testing using the spark-shell and spark-submit

.getOrElse("<unknown>")
} catch {
case sparkException: SparkException => "<unknown>"
case _: NoSuchElementException => "<unknown>"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is needed since store.environmentInfo() , can throw NoSuchElementException

Copy link
Member

Choose a reason for hiding this comment

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

cc: @sarutak

Copy link
Member

Choose a reason for hiding this comment

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

nit case _: SparkException => "<unknown>"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@SaurabhChawla100
Copy link
Contributor Author

cc @HeartSaVioR, @srowen @HyukjinKwon @dongjoon-hyun

Please review this PR

@maropu maropu changed the title [SPARK-31941][CORE]Add the code change to handle the SparkException [SPARK-31941][CORE][WEBUI] Handle SparkException in SparkUI Jun 9, 2020
@maropu
Copy link
Member

maropu commented Jun 9, 2020

ok to test

@SparkQA
Copy link

SparkQA commented Jun 9, 2020

Test build #123690 has finished for PR 28768 at commit 2b55c24.

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

@SparkQA
Copy link

SparkQA commented Jun 9, 2020

Test build #123691 has finished for PR 28768 at commit b75d168.

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

@SparkQA
Copy link

SparkQA commented Jun 9, 2020

Test build #123692 has finished for PR 28768 at commit 99584f5.

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

.getOrElse("<unknown>")
} catch {
case _: NoSuchElementException => "<unknown>"
case _: SparkException => "<unknown>"
Copy link
Member

@sarutak sarutak Jun 9, 2020

Choose a reason for hiding this comment

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

How about replacing SparkException with NoSuchElementException here?
That method threw NoSuchElementException before #28444 so I think it's better to keep the type of exception.
@HyukjinKwon suggested NoSuchElementException here but finally SparkException is used somehow.

Copy link
Member

@sarutak sarutak Jun 9, 2020

Choose a reason for hiding this comment

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

I've tried replacing SparkException with NoSuchElementException as I suggested and I can get the same error message as the screenshot shown here except the type of exception.
nosuchelement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure , I have replaced SparkException with NoSuchElementException. Please validate

@SparkQA
Copy link

SparkQA commented Jun 9, 2020

Test build #123700 has finished for PR 28768 at commit e8769fb.

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

@HeartSaVioR
Copy link
Contributor

The change looks good - we may need to reflect the "actual change" into PR title and description, as it's no longer same as initial proposal.

@SaurabhChawla100 SaurabhChawla100 changed the title [SPARK-31941][CORE][WEBUI] Handle SparkException in SparkUI [SPARK-31941][CORE] Replace SparkException from NoSuchElementException for applicationInfo in AppStatusStore Jun 10, 2020
@SaurabhChawla100 SaurabhChawla100 changed the title [SPARK-31941][CORE] Replace SparkException from NoSuchElementException for applicationInfo in AppStatusStore [SPARK-31941][CORE] Replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore Jun 10, 2020
@SaurabhChawla100
Copy link
Contributor Author

The change looks good - we may need to reflect the "actual change" into PR title and description, as it's no longer same as initial proposal.

I have updated the PR title and description in this

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

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

LGTM

@Ngone51
Copy link
Member

Ngone51 commented Jun 10, 2020

cc @xccui @jiangxb1987

@xccui
Copy link
Member

xccui commented Jun 10, 2020

Sorry that I didn't realize the potential impact of using SparkException or NoSuchElementException.

+1 to this change.

Copy link
Contributor

@jiangxb1987 jiangxb1987 left a comment

Choose a reason for hiding this comment

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

LGTM

@sarutak
Copy link
Member

sarutak commented Jun 10, 2020

Thanks all, merging into master, branch-3.0 and branch-2.4.

@sarutak sarutak closed this in 82ff29b Jun 10, 2020
sarutak pushed a commit that referenced this pull request Jun 10, 2020
…for applicationInfo in AppStatusStore

### What changes were proposed in this pull request?
After SPARK-31632 SparkException is thrown from def applicationInfo
`def applicationInfo(): v1.ApplicationInfo = {
    try {
      // The ApplicationInfo may not be available when Spark is starting up.
      store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
    } catch {
      case _: NoSuchElementException =>
        throw new SparkException("Failed to get the application information. " +
          "If you are starting up Spark, please wait a while until it's ready.")
    }
  }`

Where as the caller for this method def getSparkUser in Spark UI is not handling SparkException in the catch

`def getSparkUser: String = {
    try {
      Option(store.applicationInfo().attempts.head.sparkUser)
        .orElse(store.environmentInfo().systemProperties.toMap.get("user.name"))
        .getOrElse("<unknown>")
    } catch {
      case _: NoSuchElementException => "<unknown>"
    }
  }`

So On using this method (getSparkUser )we can get the application erred out.

As the part of this PR we will replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore

### Why are the changes needed?
On invoking the method getSparkUser, we can get the SparkException on calling store.applicationInfo(). And this is not handled in the catch block and getSparkUser will error out in this scenario

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Done the manual testing using the spark-shell and spark-submit

Closes #28768 from SaurabhChawla100/SPARK-31941.

Authored-by: SaurabhChawla <[email protected]>
Signed-off-by: Kousuke Saruta <[email protected]>
(cherry picked from commit 82ff29b)
Signed-off-by: Kousuke Saruta <[email protected]>
sarutak pushed a commit that referenced this pull request Jun 10, 2020
…for applicationInfo in AppStatusStore

### What changes were proposed in this pull request?
After SPARK-31632 SparkException is thrown from def applicationInfo
`def applicationInfo(): v1.ApplicationInfo = {
    try {
      // The ApplicationInfo may not be available when Spark is starting up.
      store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
    } catch {
      case _: NoSuchElementException =>
        throw new SparkException("Failed to get the application information. " +
          "If you are starting up Spark, please wait a while until it's ready.")
    }
  }`

Where as the caller for this method def getSparkUser in Spark UI is not handling SparkException in the catch

`def getSparkUser: String = {
    try {
      Option(store.applicationInfo().attempts.head.sparkUser)
        .orElse(store.environmentInfo().systemProperties.toMap.get("user.name"))
        .getOrElse("<unknown>")
    } catch {
      case _: NoSuchElementException => "<unknown>"
    }
  }`

So On using this method (getSparkUser )we can get the application erred out.

As the part of this PR we will replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore

### Why are the changes needed?
On invoking the method getSparkUser, we can get the SparkException on calling store.applicationInfo(). And this is not handled in the catch block and getSparkUser will error out in this scenario

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Done the manual testing using the spark-shell and spark-submit

Closes #28768 from SaurabhChawla100/SPARK-31941.

Authored-by: SaurabhChawla <[email protected]>
Signed-off-by: Kousuke Saruta <[email protected]>
(cherry picked from commit 82ff29b)
Signed-off-by: Kousuke Saruta <[email protected]>
holdenk pushed a commit to holdenk/spark that referenced this pull request Jun 25, 2020
…for applicationInfo in AppStatusStore

### What changes were proposed in this pull request?
After SPARK-31632 SparkException is thrown from def applicationInfo
`def applicationInfo(): v1.ApplicationInfo = {
    try {
      // The ApplicationInfo may not be available when Spark is starting up.
      store.view(classOf[ApplicationInfoWrapper]).max(1).iterator().next().info
    } catch {
      case _: NoSuchElementException =>
        throw new SparkException("Failed to get the application information. " +
          "If you are starting up Spark, please wait a while until it's ready.")
    }
  }`

Where as the caller for this method def getSparkUser in Spark UI is not handling SparkException in the catch

`def getSparkUser: String = {
    try {
      Option(store.applicationInfo().attempts.head.sparkUser)
        .orElse(store.environmentInfo().systemProperties.toMap.get("user.name"))
        .getOrElse("<unknown>")
    } catch {
      case _: NoSuchElementException => "<unknown>"
    }
  }`

So On using this method (getSparkUser )we can get the application erred out.

As the part of this PR we will replace SparkException to NoSuchElementException for applicationInfo in AppStatusStore

### Why are the changes needed?
On invoking the method getSparkUser, we can get the SparkException on calling store.applicationInfo(). And this is not handled in the catch block and getSparkUser will error out in this scenario

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Done the manual testing using the spark-shell and spark-submit

Closes apache#28768 from SaurabhChawla100/SPARK-31941.

Authored-by: SaurabhChawla <[email protected]>
Signed-off-by: Kousuke Saruta <[email protected]>
(cherry picked from commit 82ff29b)
Signed-off-by: Kousuke Saruta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants