YARN-11434. [Router] UGI conf doesn't read user overridden configurations on Router startup. (#6011) Contributed by Shilun Fan.

Reviewed-by: Inigo Goiri <inigoiri@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
This commit is contained in:
slfan1989 2023-09-08 07:52:54 +08:00 committed by GitHub
parent 9342ecf6cc
commit 3ab983fbae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 0 deletions

View File

@ -35,6 +35,7 @@
import org.apache.hadoop.security.AuthenticationFilterInitializer;
import org.apache.hadoop.security.HttpCrossOriginFilterInitializer;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.CompositeService;
import org.apache.hadoop.util.JvmPauseMonitor;
import org.apache.hadoop.util.ShutdownHookManager;
@ -111,6 +112,7 @@ protected void initAndStart(Configuration conf, boolean hasToReboot) {
@Override
protected void serviceInit(Configuration conf) throws Exception {
UserGroupInformation.setConfiguration(conf);
// Set up the context
this.gpgContext.setStateStoreFacade(FederationStateStoreFacade.getInstance(conf));
GPGPolicyFacade gpgPolicyFacade =

View File

@ -19,8 +19,10 @@
package org.apache.hadoop.yarn.server.globalpolicygenerator;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.service.Service;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.junit.Test;
@ -55,4 +57,15 @@ public void testGpgWithFederation() throws InterruptedException, TimeoutExceptio
return (services.size() == 1 && gpg.getWebApp() != null);
}, 100, 5000);
}
@Test
public void testUserProvidedUGIConf() throws Exception {
String errMsg = "Invalid attribute value for " +
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION + " of DUMMYAUTH";
Configuration dummyConf = new YarnConfiguration();
dummyConf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "DUMMYAUTH");
GlobalPolicyGenerator gpg = new GlobalPolicyGenerator();
LambdaTestUtils.intercept(IllegalArgumentException.class, errMsg, () -> gpg.init(dummyConf));
gpg.stop();
}
}

View File

@ -33,6 +33,7 @@
import org.apache.hadoop.metrics2.source.JvmMetrics;
import org.apache.hadoop.security.HttpCrossOriginFilterInitializer;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.service.CompositeService;
import org.apache.hadoop.util.JvmPauseMonitor;
import org.apache.hadoop.util.ShutdownHookManager;
@ -120,6 +121,7 @@ protected void doSecureLogin() throws IOException {
@Override
protected void serviceInit(Configuration config) throws Exception {
this.conf = config;
UserGroupInformation.setConfiguration(this.conf);
// ClientRM Proxy
clientRMProxyService = createClientRMProxyService();
addService(clientRMProxyService);

View File

@ -27,6 +27,7 @@
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.security.authorize.ServiceAuthorizationManager;
import org.apache.hadoop.security.http.CrossOriginFilter;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.webapp.WebApp;
import org.eclipse.jetty.servlet.FilterHolder;
@ -185,6 +186,18 @@ public void testRouterSupportCrossOrigin() throws ServletException, IOException
router.stop();
}
@Test
public void testUserProvidedUGIConf() throws Exception {
String errMsg = "Invalid attribute value for " +
CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION + " of DUMMYAUTH";
Configuration dummyConf = new YarnConfiguration();
dummyConf.set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION, "DUMMYAUTH");
Router router = new Router();
LambdaTestUtils.intercept(IllegalArgumentException.class, errMsg,
() -> router.init(dummyConf));
router.stop();
}
private class HttpServletResponseForRouterTest implements HttpServletResponse {
private final Map<String, String> headers = new HashMap<>(1);