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 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 =

View File

@ -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();
}
}