HDFS-15218. RBF: MountTableRefresherService failed to refresh other router MountTableEntries in secure mode. Contributed by Surendra Singh Lilhore.

(cherry picked from commit 8e6227441a)
This commit is contained in:
Surendra Singh Lilhore 2020-04-18 20:07:21 +05:30
parent de5d43300a
commit a6c718fd0f
2 changed files with 20 additions and 5 deletions

View File

@ -34,6 +34,8 @@
import org.apache.hadoop.hdfs.server.federation.store.StateStoreUtils; import org.apache.hadoop.hdfs.server.federation.store.StateStoreUtils;
import org.apache.hadoop.hdfs.server.federation.store.records.RouterState; import org.apache.hadoop.hdfs.server.federation.store.records.RouterState;
import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.AbstractService; import org.apache.hadoop.service.AbstractService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -170,7 +172,12 @@ public RouterClient load(String adminAddress) throws IOException {
@VisibleForTesting @VisibleForTesting
protected RouterClient createRouterClient(InetSocketAddress routerSocket, protected RouterClient createRouterClient(InetSocketAddress routerSocket,
Configuration config) throws IOException { Configuration config) throws IOException {
return new RouterClient(routerSocket, config); return SecurityUtil.doAsLoginUser(() -> {
if (UserGroupInformation.isSecurityEnabled()) {
UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
}
return new RouterClient(routerSocket, config);
});
} }
@Override @Override

View File

@ -23,6 +23,8 @@
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager; import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshMountTableEntriesRequest; import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshMountTableEntriesRequest;
import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshMountTableEntriesResponse; import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshMountTableEntriesResponse;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -61,10 +63,16 @@ public MountTableRefresherThread(MountTableManager manager,
@Override @Override
public void run() { public void run() {
try { try {
RefreshMountTableEntriesResponse refreshMountTableEntries = SecurityUtil.doAsLoginUser(() -> {
manager.refreshMountTableEntries( if (UserGroupInformation.isSecurityEnabled()) {
RefreshMountTableEntriesRequest.newInstance()); UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
success = refreshMountTableEntries.getResult(); }
RefreshMountTableEntriesResponse refreshMountTableEntries = manager
.refreshMountTableEntries(
RefreshMountTableEntriesRequest.newInstance());
success = refreshMountTableEntries.getResult();
return true;
});
} catch (IOException e) { } catch (IOException e) {
LOG.error("Failed to refresh mount table entries cache at router {}", LOG.error("Failed to refresh mount table entries cache at router {}",
adminAddress, e); adminAddress, e);