HADOOP-18592. Sasl connection failure should log remote address. (#5294)

Contributed by Viraj Jasani <vjasani@apache.org>

Signed-off-by: Chris Nauroth <cnauroth@apache.org>
Signed-off-by: Steve Loughran <stevel@apache.org>
Signed-off-by: Mingliang Liu <liuml07@apache.org>
This commit is contained in:
Viraj Jasani 2023-02-01 10:15:20 -08:00 committed by GitHub
parent 6d325d9d09
commit ad0cff2f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -704,7 +704,7 @@ private synchronized void setupConnection(
* handle that, a relogin is attempted. * handle that, a relogin is attempted.
*/ */
private synchronized void handleSaslConnectionFailure( private synchronized void handleSaslConnectionFailure(
final int currRetries, final int maxRetries, final Exception ex, final int currRetries, final int maxRetries, final IOException ex,
final Random rand, final UserGroupInformation ugi) throws IOException, final Random rand, final UserGroupInformation ugi) throws IOException,
InterruptedException { InterruptedException {
ugi.doAs(new PrivilegedExceptionAction<Object>() { ugi.doAs(new PrivilegedExceptionAction<Object>() {
@ -715,10 +715,7 @@ public Object run() throws IOException, InterruptedException {
disposeSasl(); disposeSasl();
if (shouldAuthenticateOverKrb()) { if (shouldAuthenticateOverKrb()) {
if (currRetries < maxRetries) { if (currRetries < maxRetries) {
if(LOG.isDebugEnabled()) { LOG.debug("Exception encountered while connecting to the server {}", remoteId, ex);
LOG.debug("Exception encountered while connecting to "
+ "the server : " + ex);
}
// try re-login // try re-login
if (UserGroupInformation.isLoginKeytabBased()) { if (UserGroupInformation.isLoginKeytabBased()) {
UserGroupInformation.getLoginUser().reloginFromKeytab(); UserGroupInformation.getLoginUser().reloginFromKeytab();
@ -736,7 +733,11 @@ public Object run() throws IOException, InterruptedException {
+ UserGroupInformation.getLoginUser().getUserName() + " to " + UserGroupInformation.getLoginUser().getUserName() + " to "
+ remoteId; + remoteId;
LOG.warn(msg, ex); LOG.warn(msg, ex);
throw (IOException) new IOException(msg).initCause(ex); throw NetUtils.wrapException(remoteId.getAddress().getHostName(),
remoteId.getAddress().getPort(),
NetUtils.getHostname(),
0,
ex);
} }
} else { } else {
// With RequestHedgingProxyProvider, one rpc call will send multiple // With RequestHedgingProxyProvider, one rpc call will send multiple
@ -744,11 +745,9 @@ public Object run() throws IOException, InterruptedException {
// all other requests will be interrupted. It's not a big problem, // all other requests will be interrupted. It's not a big problem,
// and should not print a warning log. // and should not print a warning log.
if (ex instanceof InterruptedIOException) { if (ex instanceof InterruptedIOException) {
LOG.debug("Exception encountered while connecting to the server", LOG.debug("Exception encountered while connecting to the server {}", remoteId, ex);
ex);
} else { } else {
LOG.warn("Exception encountered while connecting to the server ", LOG.warn("Exception encountered while connecting to the server {}", remoteId, ex);
ex);
} }
} }
if (ex instanceof RemoteException) if (ex instanceof RemoteException)