Skip to content

Conversation

@jerryshao
Copy link
Contributor

@jerryshao jerryshao commented Feb 14, 2017

What changes were proposed in this pull request?

Because yarn#client will reset the spark.yarn.keytab configuration to point to the location in distributed file, so if user still uses the old SparkConf to create SparkSession with Hive enabled, it will read keytab from the path in distributed cached. This is OK for yarn cluster mode, but in yarn client mode where driver is running out of container, it will be failed to fetch the keytab.

So here we should avoid reseting this configuration in the yarn#client and only overwriting it for AM, so using spark.yarn.keytab could get correct keytab path no matter running in client (keytab in local fs) or cluster (keytab in distributed cache) mode.

How was this patch tested?

Verified in security cluster.

@SparkQA
Copy link

SparkQA commented Feb 14, 2017

Test build #72865 has finished for PR 16923 at commit 7ed7c6c.

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

@jerryshao
Copy link
Contributor Author

@tgravescs @mridulm would you please help to review, thanks a lot.

Copy link
Contributor

@tgravescs tgravescs left a comment

Choose a reason for hiding this comment

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

mostly looks good just a small request on the comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

this seems odd, the comment seems to say that it was creating new instance of SparkConf but I don't see that in the code you removed so I guess this comment was just wrong...

It looks like this must have gotten broke when we went to spark 2.x, original version actually was creating the new SparkConf:
https://github.com/apache/spark/pull/9272/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, looks like this is a regression in 2.x.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand the comment here. This doesn't have anything to do with the user creating an old SparkConf? Isn't this just in yarn client mode it has to use the original SparkConf where yarn.Client didn't update the location of the keytab file? If that is the case perhaps just update the comment to say something to that affect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it only affects yarn client mode, in which we should get original key tab path for driver (not the one updated by yarn.Client).

@SparkQA
Copy link

SparkQA commented Feb 16, 2017

Test build #72976 has finished for PR 16923 at commit b0990e3.

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

@jerryshao
Copy link
Contributor Author

@vanzin , would you mind helping to review this PR, thanks a lot.

IIUC the issue was introduced in #11510 .

Copy link
Contributor

Choose a reason for hiding this comment

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

I probably should look at the history of this file, but I'm a little puzzled about why is this login necessary.

SparkSubmit.scala already logs in the user with the provided keytab, before YARN's Client.scala has a chance to mess with it. So it seems to me like this code is redundant?

Copy link
Contributor Author

@jerryshao jerryshao Feb 17, 2017

Choose a reason for hiding this comment

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

Not clearly sure why here login from keytab is required. Is it the behavior required by Hive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps the reason is described in here.

Copy link
Contributor

@vanzin vanzin Feb 17, 2017

Choose a reason for hiding this comment

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

That makes sense. Wish there was a different solution instead of logging in again, but let's leave that for a separate discussion...

Instead of this change, how about making Client.scala store the AM location for the keytab in a different key? As far as I can see AMCredentialRenewer is the only place where it's used. I think that would be a better change. The current change relies on spark.yarn.keytab being set as a system property so that new SparkConf() picks it up.

@SparkQA
Copy link

SparkQA commented Feb 20, 2017

Test build #73146 has finished for PR 16923 at commit 57060e3.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea of having the new conf was to avoid the changes in this file. Why are they still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK, I think we still need to check different configurations for yarn client and cluster mode. In cluster mode, checking "spark.yarn.keytab" should be failed now, since it pointed to original file which doesn't exist in AM side.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Man this is messy. Is there a better way to check where this code is running so that you don't have to to fs checks to see if the files exist? There's a very unlikely possibility that on the AM side "spark.yarn.keytab" might point at a real file that is not the desired keytab...

I also noticed that in the client case, it doesn't seem like delegation token renewal will work. I'm not sure how well that works in general in client mode anyway, but might be something worth tracking in a separate bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

One sort of hacky way is to have ApplicationMaster.scala override the value of KEYTAB in the configuration with the value of AM_KEYTAB. Then this code just needs to look at "spark.yarn.keytab" to cover both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So your suggestion is that we don't modify this HiveClientImpl code and all the changes just put into yarn module?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that would be my preference. Also my last suggestion would mean that the value of "spark.yarn.keytab" always points to the path of the keytab defined by the user, regardless of where the code is running.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I think I can see a cleaner solution that what I proposed. Sorry for flip-flopping on this.

Instead of overwriting the KEYTAB value in Client.scala, instead, how about:

  • keep the keytab name in an instance variable
  • don't update SparkConf, and use the instance variable in the distribute call (around L470)
  • when writing the AM conf, overwrite KEYTAB.key in the properties instance (around L708)

That avoids the second config, and keeps all the code to handle the different locations in one place (Client.scala), without having to change anywhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks for suggestion, let me update the code.

Change-Id: Ic0dd74361171de05dd8369919762455895e672c1
@SparkQA
Copy link

SparkQA commented Feb 23, 2017

Test build #73318 has finished for PR 16923 at commit 11bfb4f.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Change-Id: Ia77a7a6a694d01afea9a867ed11fb5d3326455f4
@SparkQA
Copy link

SparkQA commented Feb 23, 2017

Test build #73326 has finished for PR 16923 at commit 08d53d2.

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

sparkConf.getAll.foreach { case (k, v) => props.setProperty(k, v) }
// Override spark.yarn.key to point to the location in distributed cache which will be used
// by AM.
Option(amKeytabFileName).foreach(k => props.setProperty(KEYTAB.key, k))
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: either just a good old if, or .foreach { k => ... }

@vanzin
Copy link
Contributor

vanzin commented Feb 23, 2017

Can you update the title and summary to match what the change is doing?

@jerryshao jerryshao changed the title [SPARK-19038][Hive][YARN] Correctly figure out keytab file name in yarn client mode [SPARK-19038][YARN] Avoid overwriting keytab configuration in the driver side Feb 24, 2017
@jerryshao jerryshao changed the title [SPARK-19038][YARN] Avoid overwriting keytab configuration in the driver side [SPARK-19038][YARN] Avoid overwriting keytab configuration in yarn-client Feb 24, 2017
Change-Id: I57452186389651c347d6560be94c68f92249e38c
@SparkQA
Copy link

SparkQA commented Feb 24, 2017

Test build #73386 has finished for PR 16923 at commit c8390e6.

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

@vanzin
Copy link
Contributor

vanzin commented Feb 24, 2017

Merging to master (2.1 and 2.0 if no conflicts).

asfgit pushed a commit that referenced this pull request Feb 24, 2017
…ient

## What changes were proposed in this pull request?

Because yarn#client will reset the `spark.yarn.keytab` configuration to point to the location in distributed file, so if user still uses the old `SparkConf` to create `SparkSession` with Hive enabled, it will read keytab from the path in distributed cached. This is OK for yarn cluster mode, but in yarn client mode where driver is running out of container, it will be failed to fetch the keytab.

So here we should avoid reseting this configuration in the `yarn#client` and only overwriting it for AM, so using `spark.yarn.keytab` could get correct keytab path no matter running in client (keytab in local fs) or cluster (keytab in distributed cache) mode.

## How was this patch tested?

Verified in security cluster.

Author: jerryshao <[email protected]>

Closes #16923 from jerryshao/SPARK-19038.

(cherry picked from commit a920a43)
Signed-off-by: Marcelo Vanzin <[email protected]>
asfgit pushed a commit that referenced this pull request Feb 24, 2017
…ient

## What changes were proposed in this pull request?

Because yarn#client will reset the `spark.yarn.keytab` configuration to point to the location in distributed file, so if user still uses the old `SparkConf` to create `SparkSession` with Hive enabled, it will read keytab from the path in distributed cached. This is OK for yarn cluster mode, but in yarn client mode where driver is running out of container, it will be failed to fetch the keytab.

So here we should avoid reseting this configuration in the `yarn#client` and only overwriting it for AM, so using `spark.yarn.keytab` could get correct keytab path no matter running in client (keytab in local fs) or cluster (keytab in distributed cache) mode.

## How was this patch tested?

Verified in security cluster.

Author: jerryshao <[email protected]>

Closes #16923 from jerryshao/SPARK-19038.

(cherry picked from commit a920a43)
Signed-off-by: Marcelo Vanzin <[email protected]>
@asfgit asfgit closed this in a920a43 Feb 24, 2017
Yunni pushed a commit to Yunni/spark that referenced this pull request Feb 27, 2017
…ient

## What changes were proposed in this pull request?

Because yarn#client will reset the `spark.yarn.keytab` configuration to point to the location in distributed file, so if user still uses the old `SparkConf` to create `SparkSession` with Hive enabled, it will read keytab from the path in distributed cached. This is OK for yarn cluster mode, but in yarn client mode where driver is running out of container, it will be failed to fetch the keytab.

So here we should avoid reseting this configuration in the `yarn#client` and only overwriting it for AM, so using `spark.yarn.keytab` could get correct keytab path no matter running in client (keytab in local fs) or cluster (keytab in distributed cache) mode.

## How was this patch tested?

Verified in security cluster.

Author: jerryshao <[email protected]>

Closes apache#16923 from jerryshao/SPARK-19038.
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