Skip to content

Conversation

@vanzin
Copy link
Contributor

@vanzin vanzin commented Jan 25, 2018

The JVM seems to be doing early binding of classes that the Hive provider
depends on, causing an error to be thrown before it was caught by the code
in the class.

The fix wraps the creation of the provider in a try..catch so that
the provider can be ignored when dependencies are missing.

Added a unit test (which fails without the fix), and also tested
that getting tokens still works in a real cluster.

…ailable.

The JVM seems to be doing early binding of classes that the Hive provider
depends on, causing an error to be thrown before it was caught by the code
in the class.

The fix wraps the creation of the provider in a try..catch so that
the provider can be ignored when dependencies are missing.

Added a unit test (which fails without the fix), and also tested
that getting tokens still works in a real cluster.
@vanzin
Copy link
Contributor Author

vanzin commented Jan 25, 2018

@jerryshao

Copy link
Contributor

@squito squito left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise lgtm


test("SPARK-23209: obtain tokens when Hive classes are not available") {
// This test needs a custom class loader to hide Hive classes which are in the classpath.
// Because the manager code loads the Hive provider directly instead of using reflection, we
Copy link
Contributor

Choose a reason for hiding this comment

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

just for my understandning, is there any reason the manager should load the code directly, rather than using reflection to guard against this? I guess either way is fine, I just had seen us use reflection more to guard against this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Non-reflection code is easier to follow and change if needed. It makes error handling a little more complicated when classes are missing (this PR being that example), but overall I prefer that to reflection.

/** Test code for SPARK-23209 to avoid using too much reflection above. */
private object NoHiveTest extends Matchers {

def main(args: Array[String]): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

super minor: can you name this something other than "main"? it makes it seem like you're launching it as seperate process (maybe leftover from earlier attempt?)

@jerryshao
Copy link
Contributor

So seems try-catch mechanism in HiveDelegationTokenProvider is not useful.

@vanzin
Copy link
Contributor Author

vanzin commented Jan 26, 2018

Some of that could be cleaned up, but more exceptions are being caught there in different method calls, so it still can help.

@jerryshao
Copy link
Contributor

Originally we were using reflection for this HiveDelegationTokenProvider. But in that PR we changed to directly use Hive classes, is there any particular reason?

@vanzin
Copy link
Contributor Author

vanzin commented Jan 26, 2018

Because the code is cleaner that way.

@SparkQA
Copy link

SparkQA commented Jan 26, 2018

Test build #86661 has finished for PR 20399 at commit 63da171.

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

@SparkQA
Copy link

SparkQA commented Jan 26, 2018

Test build #86666 has finished for PR 20399 at commit 0a0912c.

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

@jerryshao
Copy link
Contributor

LGTM.

Some(createFn)
} catch {
case t: Throwable =>
logDebug(s"Failed to load built in provider.", t)
Copy link
Member

Choose a reason for hiding this comment

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

perhaps this should be a warn?

Copy link
Contributor

Choose a reason for hiding this comment

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

info probable - it is actually ok for this to fail if provider is not relevant (and in classpath).

Copy link
Contributor

Choose a reason for hiding this comment

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

I think debug is right, actually -- we have no idea at this point if the user wants these credential providers, and it could be totally fine if they're missing eg. if they never want to talk to hive.

(also don't really care that much and don't want to bike-shed on this ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually think this really should be debug. This only covers exceptions thrown by the constructor, which really shouldn't be doing anything (and this code is just needed because of the class linkage issue).

Individual methods like obtainDelegationTokens should be the ones reporting user-actionable issues, and even them today kinda log most things at debug level...

@sameeragarwal
Copy link
Member

@vanzin and reviewers -- is this ready to go? We're waiting on RC3 for this. Thanks!

@sameeragarwal
Copy link
Member

test this please

@vanzin
Copy link
Contributor Author

vanzin commented Jan 29, 2018

I was hoping that one of the other committers who +1'ed the patch would push it instead of me. (Ignoring the info vs. debug discussion.)

@squito
Copy link
Contributor

squito commented Jan 29, 2018

I am merging this now to master & 2.3

asfgit pushed a commit that referenced this pull request Jan 29, 2018
…ailable.

The JVM seems to be doing early binding of classes that the Hive provider
depends on, causing an error to be thrown before it was caught by the code
in the class.

The fix wraps the creation of the provider in a try..catch so that
the provider can be ignored when dependencies are missing.

Added a unit test (which fails without the fix), and also tested
that getting tokens still works in a real cluster.

Author: Marcelo Vanzin <[email protected]>

Closes #20399 from vanzin/SPARK-23209.

(cherry picked from commit b834446)
Signed-off-by: Imran Rashid <[email protected]>
@asfgit asfgit closed this in b834446 Jan 29, 2018
@SparkQA
Copy link

SparkQA commented Jan 30, 2018

Test build #86780 has finished for PR 20399 at commit 0a0912c.

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

@vanzin vanzin deleted the SPARK-23209 branch February 6, 2018 18:22
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.

7 participants