Skip to content

Commit 62c45ce

Browse files
Relogin from keytab periodically.
1 parent fa233bd commit 62c45ce

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnSparkHadoopUtil.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.spark.deploy.yarn
1919

2020
import java.io._
21-
import java.util
2221
import java.util.Arrays
2322
import java.util.Comparator
2423
import java.util.concurrent.{Executors, TimeUnit}
@@ -162,6 +161,20 @@ class YarnSparkHadoopUtil extends SparkHadoopUtil {
162161
principal, keytab)
163162
logInfo("Successfully logged into KDC.")
164163
loggedInViaKeytab = true
164+
// Not exactly sure when HDFS re-logs in, be safe and do it ourselves.
165+
// Periodically check and relogin this keytab. The UGI will take care of not relogging in
166+
// if it is not necessary to relogin.
167+
val reloginRunnable = new Runnable {
168+
override def run(): Unit = {
169+
try {
170+
loggedInUGI.checkTGTAndReloginFromKeytab()
171+
} catch {
172+
case e: Exception =>
173+
logError("Error while attempting tp relogin to KDC", e)
174+
}
175+
}
176+
}
177+
delegationTokenRenewer.schedule(reloginRunnable, 6, TimeUnit.HOURS)
165178
}
166179
val nns = getNameNodesToAccess(sparkConf)
167180
val newCredentials = loggedInUGI.getCredentials

0 commit comments

Comments
 (0)