From a95f2169450496a0be04871ad9e37be8d08616fd Mon Sep 17 00:00:00 2001 From: Rohith Sharma K S Date: Thu, 7 Jun 2018 10:25:47 +0530 Subject: [PATCH] YARN-8399. NodeManager is giving 403 GSS exception post upgrade to 3.1 in secure mode. Contributed by Sunil Govindan. (cherry picked from commit 58bc34f1e347034af566d6968eb3b3439a91cc74) --- .../containermanager/AuxServices.java | 6 +-- .../containermanager/TestAuxServices.java | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java index 3fe3cfd16ef..77c4dd9a6cb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/AuxServices.java @@ -262,7 +262,7 @@ public class AuxServices extends AbstractService } } s = AuxiliaryServiceWithCustomClassLoader.getInstance( - conf, className, dest.toString()); + new Configuration(conf), className, dest.toString()); } LOG.info("The aux service:" + sName + " are using the custom classloader"); @@ -273,7 +273,7 @@ public class AuxServices extends AbstractService if (sClass == null) { throw new RuntimeException("No class defined for " + sName); } - s = ReflectionUtils.newInstance(sClass, conf); + s = ReflectionUtils.newInstance(sClass, new Configuration(conf)); } if (s == null) { throw new RuntimeException("No object created for " + sName); @@ -294,7 +294,7 @@ public class AuxServices extends AbstractService stateStoreFs.mkdirs(storePath, storeDirPerms); s.setRecoveryPath(storePath); } - s.init(conf); + s.init(new Configuration(conf)); } catch (RuntimeException e) { LOG.error("Failed to initialize " + sName, e); throw e; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java index fcf92b509e0..ca0b32a7521 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/TestAuxServices.java @@ -678,4 +678,52 @@ public class TestAuxServices { super("RecoverableServiceB", "Bsrv"); } } + + static class ConfChangeAuxService extends AuxiliaryService + implements Service { + + ConfChangeAuxService() { + super("ConfChangeAuxService"); + } + + @Override + protected void serviceInit(Configuration conf) throws Exception { + conf.set("dummyConfig", "changedTestValue"); + super.serviceInit(conf); + } + + @Override + public void initializeApplication( + ApplicationInitializationContext initAppContext) { + } + + @Override + public void stopApplication(ApplicationTerminationContext stopAppContext) { + } + + @Override + public ByteBuffer getMetaData() { + return null; + } + } + + @Test + public void testAuxServicesConfChange() { + Configuration conf = new Configuration(); + conf.setStrings(YarnConfiguration.NM_AUX_SERVICES, + new String[]{"ConfChangeAuxService"}); + conf.setClass(String.format(YarnConfiguration.NM_AUX_SERVICE_FMT, + "ConfChangeAuxService"), ConfChangeAuxService.class, Service.class); + AuxServices aux = new AuxServices(MOCK_AUX_PATH_HANDLER, MOCK_CONTEXT, + MOCK_DEL_SERVICE); + conf.set("dummyConfig", "testValue"); + aux.init(conf); + aux.start(); + for (AuxiliaryService s : aux.getServices()) { + assertEquals(STARTED, s.getServiceState()); + assertEquals(conf.get("dummyConfig"), "testValue"); + } + + aux.stop(); + } }