YARN-8132. Final Status of applications shown as UNDEFINED in ATS app queries. Contributed by Prabhu Joseph

This commit is contained in:
bibinchundatt 2019-02-22 20:46:54 +05:30
parent d75aa33612
commit cf1944eb6e
3 changed files with 34 additions and 24 deletions

View File

@ -1372,7 +1372,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
setTrackingUrlToRMAppPage(stateToBeStored); setTrackingUrlToRMAppPage(stateToBeStored);
} }
String finalTrackingUrl = getOriginalTrackingUrl(); String finalTrackingUrl = getOriginalTrackingUrl();
FinalApplicationStatus finalStatus = null; FinalApplicationStatus status = null;
int exitStatus = ContainerExitStatus.INVALID; int exitStatus = ContainerExitStatus.INVALID;
switch (event.getType()) { switch (event.getType()) {
case LAUNCH_FAILED: case LAUNCH_FAILED:
@ -1387,7 +1387,7 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
diags.append(unregisterEvent.getDiagnosticMsg()); diags.append(unregisterEvent.getDiagnosticMsg());
// reset finalTrackingUrl to url sent by am // reset finalTrackingUrl to url sent by am
finalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl()); finalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl());
finalStatus = unregisterEvent.getFinalApplicationStatus(); status = unregisterEvent.getFinalApplicationStatus();
break; break;
case CONTAINER_FINISHED: case CONTAINER_FINISHED:
RMAppAttemptContainerFinishedEvent finishEvent = RMAppAttemptContainerFinishedEvent finishEvent =
@ -1396,8 +1396,10 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
exitStatus = finishEvent.getContainerStatus().getExitStatus(); exitStatus = finishEvent.getContainerStatus().getExitStatus();
break; break;
case KILL: case KILL:
status = FinalApplicationStatus.KILLED;
break; break;
case FAIL: case FAIL:
status = FinalApplicationStatus.FAILED;
diags.append(event.getDiagnosticMsg()); diags.append(event.getDiagnosticMsg());
break; break;
case EXPIRE: case EXPIRE:
@ -1414,13 +1416,14 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
ApplicationAttemptStateData attemptState = ApplicationAttemptStateData ApplicationAttemptStateData attemptState = ApplicationAttemptStateData
.newInstance(applicationAttemptId, getMasterContainer(), .newInstance(applicationAttemptId, getMasterContainer(),
rmStore.getCredentialsFromAppAttempt(this), startTime, rmStore.getCredentialsFromAppAttempt(this), startTime,
stateToBeStored, finalTrackingUrl, diags.toString(), finalStatus, exitStatus, stateToBeStored, finalTrackingUrl, diags.toString(), status,
getFinishTime(), resUsage.getResourceUsageSecondsMap(), exitStatus, getFinishTime(), resUsage.getResourceUsageSecondsMap(),
this.attemptMetrics.getPreemptedResourceSecondsMap()); this.attemptMetrics.getPreemptedResourceSecondsMap());
LOG.info("Updating application attempt " + applicationAttemptId LOG.info("Updating application attempt " + applicationAttemptId
+ " with final state: " + targetedFinalState + ", and exit status: " + " with final state: " + targetedFinalState + ", and exit status: "
+ exitStatus); + exitStatus);
rmStore.updateApplicationAttemptState(attemptState); rmStore.updateApplicationAttemptState(attemptState);
finalStatus = status;
} }
private static class FinalSavingTransition extends BaseTransition { private static class FinalSavingTransition extends BaseTransition {
@ -1916,7 +1919,6 @@ public class RMAppAttemptImpl implements RMAppAttempt, Recoverable {
(RMAppAttemptUnregistrationEvent) event; (RMAppAttemptUnregistrationEvent) event;
this.diagnostics.append(unregisterEvent.getDiagnosticMsg()); this.diagnostics.append(unregisterEvent.getDiagnosticMsg());
originalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl()); originalTrackingUrl = sanitizeTrackingUrl(unregisterEvent.getFinalTrackingUrl());
finalStatus = unregisterEvent.getFinalApplicationStatus();
} }
private static final class ContainerFinishedTransition private static final class ContainerFinishedTransition

View File

@ -694,7 +694,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
assertAppFinalStateNotSaved(application); assertAppFinalStateNotSaved(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -713,7 +713,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertFailed(application, rejectedText); assertFailed(application, rejectedText);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -731,7 +731,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertFailed(application, rejectedText); assertFailed(application, rejectedText);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
rmContext.getStateStore().removeApplication(application); rmContext.getStateStore().removeApplication(application);
} }
@ -753,7 +753,7 @@ public class TestRMAppTransitions {
rmDispatcher.await(); rmDispatcher.await();
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -772,7 +772,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertFailed(application, rejectedText); assertFailed(application, rejectedText);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -789,7 +789,7 @@ public class TestRMAppTransitions {
assertFailed(application, rejectedText); assertFailed(application, rejectedText);
verify(store, times(0)).updateApplicationState( verify(store, times(0)).updateApplicationState(
any(ApplicationStateData.class)); any(ApplicationStateData.class));
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
assertTimesAtFinish(application); assertTimesAtFinish(application);
} }
@ -807,7 +807,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertFailed(application, rejectedText); assertFailed(application, rejectedText);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -829,7 +829,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -866,7 +866,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertFailed(application, ".*" + message + ".*Failing the application.*"); assertFailed(application, ".*" + message + ".*Failing the application.*");
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
} }
@Test @Test
@ -893,7 +893,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -917,7 +917,7 @@ public class TestRMAppTransitions {
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
} }
@ -941,7 +941,7 @@ public class TestRMAppTransitions {
sendAttemptUpdateSavedEvent(application); sendAttemptUpdateSavedEvent(application);
sendAppUpdateSavedEvent(application); sendAppUpdateSavedEvent(application);
assertKilled(application); assertKilled(application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
verifyAppRemovedSchedulerEvent(RMAppState.KILLED); verifyAppRemovedSchedulerEvent(RMAppState.KILLED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -1000,7 +1000,7 @@ public class TestRMAppTransitions {
rmDispatcher.await(); rmDispatcher.await();
assertFailed(application, ".*Failing the application.*"); assertFailed(application, ".*Failing the application.*");
assertAppFinalStateSaved(application); assertAppFinalStateSaved(application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -1062,7 +1062,9 @@ public class TestRMAppTransitions {
StringBuilder diag = application.getDiagnostics(); StringBuilder diag = application.getDiagnostics();
Assert.assertEquals("application diagnostics is not correct", Assert.assertEquals("application diagnostics is not correct",
"", diag.toString()); "", diag.toString());
verifyApplicationFinished(RMAppState.FINISHED); // finished without a proper final state is the same as failed
verifyApplicationFinished(RMAppState.FINISHED,
FinalApplicationStatus.FAILED);
verifyRMAppFieldsForFinalTransitions(application); verifyRMAppFieldsForFinalTransitions(application);
} }
@ -1089,7 +1091,7 @@ public class TestRMAppTransitions {
rmDispatcher.await(); rmDispatcher.await();
assertTimesAtFinish(application); assertTimesAtFinish(application);
assertAppState(RMAppState.FAILED, application); assertAppState(RMAppState.FAILED, application);
verifyApplicationFinished(RMAppState.FAILED); verifyApplicationFinished(RMAppState.FAILED, FinalApplicationStatus.FAILED);
assertTimesAtFinish(application); assertTimesAtFinish(application);
assertAppState(RMAppState.FAILED, application); assertAppState(RMAppState.FAILED, application);
@ -1144,7 +1146,7 @@ public class TestRMAppTransitions {
rmDispatcher.await(); rmDispatcher.await();
assertTimesAtFinish(application); assertTimesAtFinish(application);
assertAppState(RMAppState.KILLED, application); assertAppState(RMAppState.KILLED, application);
verifyApplicationFinished(RMAppState.KILLED); verifyApplicationFinished(RMAppState.KILLED, FinalApplicationStatus.KILLED);
assertTimesAtFinish(application); assertTimesAtFinish(application);
assertAppState(RMAppState.KILLED, application); assertAppState(RMAppState.KILLED, application);
@ -1257,15 +1259,20 @@ public class TestRMAppTransitions {
+ "/")); + "/"));
} }
private void verifyApplicationFinished(RMAppState state) { private void verifyApplicationFinished(RMAppState state,
FinalApplicationStatus finalAppStatus) {
ArgumentCaptor<RMAppState> finalState = ArgumentCaptor<RMAppState> finalState =
ArgumentCaptor.forClass(RMAppState.class); ArgumentCaptor.forClass(RMAppState.class);
verify(writer).applicationFinished(any(RMApp.class), finalState.capture()); verify(writer).applicationFinished(any(RMApp.class), finalState.capture());
Assert.assertEquals(state, finalState.getValue()); Assert.assertEquals(state, finalState.getValue());
finalState = ArgumentCaptor.forClass(RMAppState.class); finalState = ArgumentCaptor.forClass(RMAppState.class);
verify(publisher).appFinished(any(RMApp.class), finalState.capture(), ArgumentCaptor<RMApp> app =
ArgumentCaptor.forClass(RMApp.class);
verify(publisher).appFinished(app.capture(), finalState.capture(),
anyLong()); anyLong());
Assert.assertEquals(state, finalState.getValue()); Assert.assertEquals(state, finalState.getValue());
Assert.assertEquals(finalAppStatus,
app.getValue().getFinalApplicationStatus());
} }
private void verifyAppRemovedSchedulerEvent(RMAppState finalState) { private void verifyAppRemovedSchedulerEvent(RMAppState finalState) {

View File

@ -442,7 +442,8 @@ public class TestRMAppAttemptTransitions {
assertEquals(amContainer, applicationAttempt.getMasterContainer()); assertEquals(amContainer, applicationAttempt.getMasterContainer());
assertEquals(0.0, (double)applicationAttempt.getProgress(), 0.0001); assertEquals(0.0, (double)applicationAttempt.getProgress(), 0.0001);
assertEquals(0, application.getRanNodes().size()); assertEquals(0, application.getRanNodes().size());
assertNull(applicationAttempt.getFinalApplicationStatus()); assertEquals(FinalApplicationStatus.KILLED,
applicationAttempt.getFinalApplicationStatus());
verifyTokenCount(applicationAttempt.getAppAttemptId(), 1); verifyTokenCount(applicationAttempt.getAppAttemptId(), 1);
verifyAttemptFinalStateSaved(); verifyAttemptFinalStateSaved();
assertFalse(transferStateFromPreviousAttempt); assertFalse(transferStateFromPreviousAttempt);