From 30b20969336126efe989e5e913d446645a2cb8fc Mon Sep 17 00:00:00 2001 From: Prabhu Joseph Date: Mon, 18 Nov 2019 22:42:20 +0530 Subject: [PATCH] YARN-9986. Allow app owner to signal container via RMWebServices. Contributed by kyungwan nam. --- .../resourcemanager/webapp/RMWebServices.java | 2 +- .../webapp/TestRMWebServicesContainers.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java index d263830f663..f2f03a64cc9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/RMWebServices.java @@ -2780,7 +2780,7 @@ public class RMWebServices extends WebServices implements RMWebServiceProtocol { @Context HttpServletRequest hsr) throws AuthorizationException { UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); - initForWritableEndpoints(callerUGI, true); + initForWritableEndpoints(callerUGI, false); if (!EnumUtils.isValidEnum( SignalContainerCommand.class, command.toUpperCase())) { String errMsg = diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesContainers.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesContainers.java index d2a94c135dc..76e7f7b9129 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesContainers.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/TestRMWebServicesContainers.java @@ -73,7 +73,7 @@ public class TestRMWebServicesContainers extends JerseyTestBase { Configuration conf = new Configuration(); conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, ResourceScheduler.class); - conf.set(YarnConfiguration.YARN_ADMIN_ACL, userName); + conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin"); rm = new MockRM(conf); bind(ResourceManager.class).toInstance(rm); serve("/*").with(GuiceContainer.class); @@ -141,7 +141,7 @@ public class TestRMWebServicesContainers extends JerseyTestBase { assertTrue( response.getEntity(String.class).contains("Invalid ContainerId")); - // test correct signal + // test correct signal by owner response = r.path("ws").path("v1").path("cluster").path("containers").path( app.getCurrentAppAttempt().getMasterContainer().getId().toString()) @@ -153,6 +153,18 @@ public class TestRMWebServicesContainers extends JerseyTestBase { response.getType().toString()); assertEquals(Response.SC_OK, response.getStatus()); + // test correct signal by admin + response = + r.path("ws").path("v1").path("cluster").path("containers").path( + app.getCurrentAppAttempt().getMasterContainer().getId().toString()) + .path("signal") + .path(SignalContainerCommand.OUTPUT_THREAD_DUMP.name()) + .queryParam("user.name", "admin") + .accept(MediaType.APPLICATION_JSON).post(ClientResponse.class); + assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8, + response.getType().toString()); + assertEquals(Response.SC_OK, response.getStatus()); + rm.stop(); } }