YARN-4408. Fix issue that NodeManager still reports negative running containers. Contributed by Robert Kanter.
(cherry picked from commit62e9348bc1
) (cherry picked from commite76ba91fa5
)
This commit is contained in:
parent
78552d8857
commit
6af5255b02
|
@ -1020,6 +1020,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
YARN-4384. updateNodeResource CLI should not accept negative values for resource.
|
YARN-4384. updateNodeResource CLI should not accept negative values for resource.
|
||||||
(Junping Du via wangda)
|
(Junping Du via wangda)
|
||||||
|
|
||||||
|
YARN-4408. Fix issue that NodeManager reports negative running containers.
|
||||||
|
(Robert Kanter via junping_du)
|
||||||
|
|
||||||
Release 2.7.3 - UNRELEASED
|
Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -1041,7 +1041,12 @@ public class ContainerImpl implements Container {
|
||||||
ContainerDoneTransition {
|
ContainerDoneTransition {
|
||||||
@Override
|
@Override
|
||||||
public void transition(ContainerImpl container, ContainerEvent event) {
|
public void transition(ContainerImpl container, ContainerEvent event) {
|
||||||
|
if (container.wasLaunched) {
|
||||||
container.metrics.endRunningContainer();
|
container.metrics.endRunningContainer();
|
||||||
|
} else {
|
||||||
|
LOG.warn("Container exited with success despite being killed and not" +
|
||||||
|
"actually running");
|
||||||
|
}
|
||||||
container.metrics.completedContainer();
|
container.metrics.completedContainer();
|
||||||
NMAuditLogger.logSuccess(container.user,
|
NMAuditLogger.logSuccess(container.user,
|
||||||
AuditConstants.FINISH_SUCCESS_CONTAINER, "ContainerImpl",
|
AuditConstants.FINISH_SUCCESS_CONTAINER, "ContainerImpl",
|
||||||
|
|
|
@ -397,7 +397,8 @@ public class TestContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKillOnLocalizedWhenContainerNotLaunched() throws Exception {
|
public void testKillOnLocalizedWhenContainerNotLaunchedContainerKilled()
|
||||||
|
throws Exception {
|
||||||
WrappedContainer wc = null;
|
WrappedContainer wc = null;
|
||||||
try {
|
try {
|
||||||
wc = new WrappedContainer(17, 314159265358979L, 4344, "yak");
|
wc = new WrappedContainer(17, 314159265358979L, 4344, "yak");
|
||||||
|
@ -426,6 +427,62 @@ public class TestContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testKillOnLocalizedWhenContainerNotLaunchedContainerSuccess()
|
||||||
|
throws Exception {
|
||||||
|
WrappedContainer wc = null;
|
||||||
|
try {
|
||||||
|
wc = new WrappedContainer(17, 314159265358979L, 4344, "yak");
|
||||||
|
wc.initContainer();
|
||||||
|
wc.localizeResources();
|
||||||
|
assertEquals(ContainerState.LOCALIZED, wc.c.getContainerState());
|
||||||
|
wc.killContainer();
|
||||||
|
assertEquals(ContainerState.KILLING, wc.c.getContainerState());
|
||||||
|
wc.containerSuccessful();
|
||||||
|
wc.drainDispatcherEvents();
|
||||||
|
assertEquals(ContainerState.EXITED_WITH_SUCCESS,
|
||||||
|
wc.c.getContainerState());
|
||||||
|
assertNull(wc.c.getLocalizedResources());
|
||||||
|
verifyCleanupCall(wc);
|
||||||
|
wc.c.handle(new ContainerEvent(wc.c.getContainerId(),
|
||||||
|
ContainerEventType.CONTAINER_RESOURCES_CLEANEDUP));
|
||||||
|
assertEquals(ContainerState.DONE, wc.c.getContainerState());
|
||||||
|
assertEquals(0, metrics.getRunningContainers());
|
||||||
|
} finally {
|
||||||
|
if (wc != null) {
|
||||||
|
wc.finished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testKillOnLocalizedWhenContainerNotLaunchedContainerFailure()
|
||||||
|
throws Exception {
|
||||||
|
WrappedContainer wc = null;
|
||||||
|
try {
|
||||||
|
wc = new WrappedContainer(17, 314159265358979L, 4344, "yak");
|
||||||
|
wc.initContainer();
|
||||||
|
wc.localizeResources();
|
||||||
|
assertEquals(ContainerState.LOCALIZED, wc.c.getContainerState());
|
||||||
|
wc.killContainer();
|
||||||
|
assertEquals(ContainerState.KILLING, wc.c.getContainerState());
|
||||||
|
wc.containerFailed(ExitCode.FORCE_KILLED.getExitCode());
|
||||||
|
wc.drainDispatcherEvents();
|
||||||
|
assertEquals(ContainerState.EXITED_WITH_FAILURE,
|
||||||
|
wc.c.getContainerState());
|
||||||
|
assertNull(wc.c.getLocalizedResources());
|
||||||
|
verifyCleanupCall(wc);
|
||||||
|
wc.c.handle(new ContainerEvent(wc.c.getContainerId(),
|
||||||
|
ContainerEventType.CONTAINER_RESOURCES_CLEANEDUP));
|
||||||
|
assertEquals(ContainerState.DONE, wc.c.getContainerState());
|
||||||
|
assertEquals(0, metrics.getRunningContainers());
|
||||||
|
} finally {
|
||||||
|
if (wc != null) {
|
||||||
|
wc.finished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testKillOnLocalizedWhenContainerLaunched() throws Exception {
|
public void testKillOnLocalizedWhenContainerLaunched() throws Exception {
|
||||||
WrappedContainer wc = null;
|
WrappedContainer wc = null;
|
||||||
|
|
Loading…
Reference in New Issue