YARN-9986. Allow app owner to signal container via RMWebServices. Contributed by kyungwan nam.

This commit is contained in:
Prabhu Joseph 2019-11-18 22:42:20 +05:30 committed by prabhujoseph
parent 3cecb2a469
commit 30b2096933
2 changed files with 15 additions and 3 deletions

View File

@ -2780,7 +2780,7 @@ public Response signalToContainer(
@Context HttpServletRequest hsr) @Context HttpServletRequest hsr)
throws AuthorizationException { throws AuthorizationException {
UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true); UserGroupInformation callerUGI = getCallerUserGroupInformation(hsr, true);
initForWritableEndpoints(callerUGI, true); initForWritableEndpoints(callerUGI, false);
if (!EnumUtils.isValidEnum( if (!EnumUtils.isValidEnum(
SignalContainerCommand.class, command.toUpperCase())) { SignalContainerCommand.class, command.toUpperCase())) {
String errMsg = String errMsg =

View File

@ -73,7 +73,7 @@ protected void configureServlets() {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class, conf.setClass(YarnConfiguration.RM_SCHEDULER, FifoScheduler.class,
ResourceScheduler.class); ResourceScheduler.class);
conf.set(YarnConfiguration.YARN_ADMIN_ACL, userName); conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
rm = new MockRM(conf); rm = new MockRM(conf);
bind(ResourceManager.class).toInstance(rm); bind(ResourceManager.class).toInstance(rm);
serve("/*").with(GuiceContainer.class); serve("/*").with(GuiceContainer.class);
@ -141,7 +141,7 @@ public void testSignalContainer() throws Exception {
assertTrue( assertTrue(
response.getEntity(String.class).contains("Invalid ContainerId")); response.getEntity(String.class).contains("Invalid ContainerId"));
// test correct signal // test correct signal by owner
response = response =
r.path("ws").path("v1").path("cluster").path("containers").path( r.path("ws").path("v1").path("cluster").path("containers").path(
app.getCurrentAppAttempt().getMasterContainer().getId().toString()) app.getCurrentAppAttempt().getMasterContainer().getId().toString())
@ -153,6 +153,18 @@ public void testSignalContainer() throws Exception {
response.getType().toString()); response.getType().toString());
assertEquals(Response.SC_OK, response.getStatus()); 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(); rm.stop();
} }
} }