YARN-4152. NodeManager crash with NPE when LogAggregationService#stopContainer called for absent container. (Bibin A Chundatt via rohithsharmaks)

This commit is contained in:
Rohith Sharma K S 2015-09-24 11:24:14 +05:30
parent 3d8f6b9d48
commit ace4d26936
3 changed files with 31 additions and 2 deletions

View File

@ -819,6 +819,9 @@ Release 2.8.0 - UNRELEASED
YARN-4188. Make MoveApplicationAcrossQueues abstract, newInstance static.
(Giovanni Matteo Fumarola via cdouglas)
YARN-4152. NodeManager crash with NPE when LogAggregationService#stopContainer called for
absent container. (Bibin A Chundatt via rohithsharmaks)
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES

View File

@ -56,6 +56,7 @@ import org.apache.hadoop.yarn.server.nodemanager.DeletionService;
import org.apache.hadoop.yarn.server.nodemanager.LocalDirsHandlerService;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEvent;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationEventType;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.loghandler.LogHandler;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.loghandler.event.LogHandlerAppFinishedEvent;
import org.apache.hadoop.yarn.server.nodemanager.containermanager.loghandler.event.LogHandlerAppStartedEvent;
@ -423,8 +424,14 @@ public class LogAggregationService extends AbstractService implements
+ ", did it fail to start?");
return;
}
ContainerType containerType = context.getContainers().get(
containerId).getContainerTokenIdentifier().getContainerType();
Container container = context.getContainers().get(containerId);
if (null == container) {
LOG.warn("Log aggregation cannot be started for " + containerId
+ ", as its an absent container");
return;
}
ContainerType containerType =
container.getContainerTokenIdentifier().getContainerType();
aggregator.startContainerLogAggregation(
new ContainerLogContext(containerId, containerType, exitCode));
}

View File

@ -1509,6 +1509,25 @@ public class TestLogAggregationService extends BaseContainerManagerTest {
verifyLogAggFinishEvent(appId);
}
@Test(timeout = 50000)
public void testLogAggregationAbsentContainer() throws Exception {
ApplicationId appId = createApplication();
LogAggregationService logAggregationService =
createLogAggregationService(appId,
FailedOrKilledContainerLogAggregationPolicy.class, null);
ApplicationAttemptId appAttemptId1 =
BuilderUtils.newApplicationAttemptId(appId, 1);
ContainerId containerId = BuilderUtils.newContainerId(appAttemptId1, 2l);
try {
logAggregationService.handle(new LogHandlerContainerFinishedEvent(
containerId, 100));
assertTrue("Should skip when null containerID", true);
} catch (Exception e) {
Assert.assertFalse("Exception not expected should skip null containerid",
true);
}
}
@Test (timeout = 50000)
@SuppressWarnings("unchecked")
public void testAMOnlyContainerPolicy() throws Exception {