Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions server/src/main/scala/org/apache/livy/server/LivyServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -361,27 +361,33 @@ class LivyServer extends Logging {
executor.schedule(
new Runnable() {
override def run(): Unit = {
if (runKinit(keytab, principal)) {
// The current UGI should never change. If that happens, it is an error condition and
// relogin the original UGI would not update the current UGI. So the server will fail
// due to no valid credentials. The assert here allows to fast detect this error
// condition and fail immediately with a meaningful error.
assert(ugi.equals(UserGroupInformation.getCurrentUser), "Current UGI has changed.")
ugi.reloginFromTicketCache()
// schedule another kinit run with a fixed delay.
executor.schedule(this, refreshInterval, TimeUnit.MILLISECONDS)
} else {
// schedule another retry at once or fail the livy server if too many times kinit fail
if (kinitFailCount >= kinitFailThreshold) {
error(s"Exit LivyServer after ${kinitFailThreshold} times failures running kinit.")
if (server.server.isStarted()) {
stop()
try {
if (runKinit(keytab, principal)) {
// The current UGI should never change. If that happens, it is an error condition and
// relogin the original UGI would not update the current UGI. So the server will fail
// due to no valid credentials. The assert here allows to fast detect this error
// condition and fail immediately with a meaningful error.
assert(ugi.equals(UserGroupInformation.getCurrentUser), "Current UGI has changed.")
ugi.reloginFromTicketCache()
// schedule another kinit run with a fixed delay.
executor.schedule(this, refreshInterval, TimeUnit.MILLISECONDS)
} else {
// schedule another retry at once or fail the livy server if too many times kinit fail
if (kinitFailCount >= kinitFailThreshold) {
error(s"Exit LivyServer after ${kinitFailThreshold} times failures running kinit.")
if (server.server.isStarted()) {
stop()
} else {
sys.exit(1)
}
} else {
sys.exit(1)
executor.submit(this)
}
} else {
executor.submit(this)
}
} catch {
case e: Throwable =>
error("Exception thrown in kinit thread", e)
executor.submit(this)
}
}
}, refreshInterval, TimeUnit.MILLISECONDS)
Expand Down