浏览代码

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)
Rohith Sharma K S 7 年之前
父节点
当前提交
a95f216945

+ 3 - 3
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;

+ 48 - 0
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();
+  }
 }