|
@@ -123,6 +123,7 @@ import org.apache.hadoop.util.ExitUtil;
|
|
|
import org.apache.hadoop.util.ProtoUtil;
|
|
|
import org.apache.hadoop.util.StringUtils;
|
|
|
import org.apache.hadoop.util.Time;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import org.apache.hadoop.tracing.Span;
|
|
|
import org.apache.hadoop.tracing.SpanContext;
|
|
|
import org.apache.hadoop.tracing.TraceScope;
|
|
@@ -153,6 +154,13 @@ public abstract class Server {
|
|
|
private ExceptionsHandler exceptionsHandler = new ExceptionsHandler();
|
|
|
private Tracer tracer;
|
|
|
private AlignmentContext alignmentContext;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Allow server to do force Kerberos re-login once after failure irrespective
|
|
|
+ * of the last login time.
|
|
|
+ */
|
|
|
+ private final AtomicBoolean canTryForceLogin = new AtomicBoolean(true);
|
|
|
+
|
|
|
/**
|
|
|
* Logical name of the server used in metrics and monitor.
|
|
|
*/
|
|
@@ -2206,7 +2214,23 @@ public abstract class Server {
|
|
|
AUDITLOG.warn(AUTH_FAILED_FOR + this.toString() + ":"
|
|
|
+ attemptingUser + " (" + e.getLocalizedMessage()
|
|
|
+ ") with true cause: (" + tce.getLocalizedMessage() + ")");
|
|
|
- throw tce;
|
|
|
+ if (!UserGroupInformation.getLoginUser().isLoginSuccess()) {
|
|
|
+ doKerberosRelogin();
|
|
|
+ try {
|
|
|
+ // try processing message again
|
|
|
+ LOG.debug("Reprocessing sasl message for {}:{} after re-login",
|
|
|
+ this.toString(), attemptingUser);
|
|
|
+ saslResponse = processSaslMessage(saslMessage);
|
|
|
+ AUDITLOG.info("Retry {}{}:{} after failure", AUTH_SUCCESSFUL_FOR,
|
|
|
+ this.toString(), attemptingUser);
|
|
|
+ canTryForceLogin.set(true);
|
|
|
+ } catch (IOException exp) {
|
|
|
+ tce = (IOException) getTrueCause(e);
|
|
|
+ throw tce;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw tce;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (saslServer != null && saslServer.isComplete()) {
|
|
@@ -3322,6 +3346,26 @@ public abstract class Server {
|
|
|
metricsUpdaterInterval, metricsUpdaterInterval, TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
|
|
|
+ private synchronized void doKerberosRelogin() throws IOException {
|
|
|
+ if(UserGroupInformation.getLoginUser().isLoginSuccess()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LOG.warn("Initiating re-login from IPC Server");
|
|
|
+ if (canTryForceLogin.compareAndSet(true, false)) {
|
|
|
+ if (UserGroupInformation.isLoginKeytabBased()) {
|
|
|
+ UserGroupInformation.getLoginUser().forceReloginFromKeytab();
|
|
|
+ } else if (UserGroupInformation.isLoginTicketBased()) {
|
|
|
+ UserGroupInformation.getLoginUser().forceReloginFromTicketCache();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (UserGroupInformation.isLoginKeytabBased()) {
|
|
|
+ UserGroupInformation.getLoginUser().reloginFromKeytab();
|
|
|
+ } else if (UserGroupInformation.isLoginTicketBased()) {
|
|
|
+ UserGroupInformation.getLoginUser().reloginFromTicketCache();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public synchronized void addAuxiliaryListener(int auxiliaryPort)
|
|
|
throws IOException {
|
|
|
if (auxiliaryListenerMap == null) {
|