Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-8224] [runtime] shutdown application when job terminated in job mode #5139

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.flink.api.common.JobID;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.blob.BlobServer;
import org.apache.flink.runtime.clusterframework.ApplicationStatus;
import org.apache.flink.runtime.clusterframework.types.ResourceID;
import org.apache.flink.runtime.heartbeat.HeartbeatServices;
import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
Expand Down Expand Up @@ -152,8 +153,11 @@ protected void stopClusterComponents(boolean cleanupHaData) throws Exception {
}
}

private void shutDownAndTerminate(boolean cleanupHaData) {
private void shutDownAndTerminate(boolean cleanupHaData, ApplicationStatus status, String optionalDiagnostics) {
try {
if (resourceManager != null) {
resourceManager.shutDownCluster(status, optionalDiagnostics);
}
shutDown(cleanupHaData);
} catch (Throwable t) {
LOG.error("Could not properly shut down cluster entrypoint.", t);
Expand Down Expand Up @@ -185,21 +189,21 @@ private TerminatingOnCompleteActions(JobID jobId) {
public void jobFinished(JobExecutionResult result) {
LOG.info("Job({}) finished.", jobId);

shutDownAndTerminate(true);
shutDownAndTerminate(true, ApplicationStatus.SUCCEEDED, null);
}

@Override
public void jobFailed(Throwable cause) {
LOG.info("Job({}) failed.", jobId, cause);

shutDownAndTerminate(false);
shutDownAndTerminate(false, ApplicationStatus.FAILED, cause.getMessage());
}

@Override
public void jobFinishedByOther() {
LOG.info("Job({}) was finished by another JobManager.", jobId);

shutDownAndTerminate(false);
shutDownAndTerminate(false, ApplicationStatus.UNKNOWN, "Job was finished by another master");
}
}
}