Skip to content

Commit

Permalink
[SPARK-22374][SQL][2.2] closeAllForUGI is required after using loginU…
Browse files Browse the repository at this point in the history
…serFromKeytab
  • Loading branch information
dongjoon-hyun committed Oct 28, 2017
1 parent cb54f29 commit ea3943e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hive.common.cli.HiveFileProcessor;
import org.apache.hadoop.hive.common.cli.IHiveFileProcessor;
import org.apache.hadoop.hive.conf.HiveConf;
Expand All @@ -47,6 +48,7 @@
import org.apache.hadoop.hive.ql.processors.SetProcessor;
import org.apache.hadoop.hive.ql.session.SessionState;
import org.apache.hadoop.hive.shims.ShimLoader;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hive.common.util.HiveVersionInfo;
import org.apache.hive.service.auth.HiveAuthFactory;
import org.apache.hive.service.cli.FetchOrientation;
Expand Down Expand Up @@ -565,6 +567,11 @@ public void close() throws HiveSQLException {
}
try {
sessionState.close();
if (hiveConf.get("spark.yarn.principal") != null &&
hiveConf.get("spark.yarn.keytab") != null) {
LOG.info("closeAllForUGI: " + UserGroupInformation.getCurrentUser().hashCode());
FileSystem.closeAllForUGI(UserGroupInformation.getCurrentUser());
}
} finally {
sessionState = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ private[hive] class HiveClientImpl(
throw new SparkException(s"Keytab file: ${keytabFileName}" +
" specified in spark.yarn.keytab does not exist")
} else {
logInfo(s"Old UGI(hashcode): ${UserGroupInformation.getCurrentUser.hashCode}")
logInfo("Attempting to login to Kerberos" +
s" using principal: ${principalName} and keytab: ${keytabFileName}")
UserGroupInformation.loginUserFromKeytab(principalName, keytabFileName)
logInfo(s"Session UGI(hashcode): ${UserGroupInformation.getCurrentUser.hashCode}")
}
}

Expand Down

0 comments on commit ea3943e

Please sign in to comment.