Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8501d7

Browse files
committed
fix(deploy): fail a deploy job on unhealthy instance state
1 parent fd738dd commit a8501d7

File tree

3 files changed

+167
-119
lines changed

3 files changed

+167
-119
lines changed

src/main/java/com/conveyal/datatools/common/status/MonitorableJob.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ public void run () {
181181
// TODO: should we add separate hooks depending on state of job/sub-tasks (e.g., success, catch, finally)
182182
// Set status to finished in case duration needed by finishing stage. (e.g., storing the job duration in a
183183
// database).
184-
status.completeSuccessfully("Job complete!");
184+
if (cancelMessage.equals("")) {
185+
status.completeSuccessfully("Job complete!");
186+
}
185187
jobFinished();
186188

187189
// We retain finished or errored jobs on the server until they are fetched via the API, which implies they

src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,14 @@ private void replaceEC2Servers() {
512512
);
513513
monitorInitialServerJob.run();
514514

515+
if (monitorInitialServerJob.status.error) {
516+
// If an error occurred while monitoring the initial server, fail this job and instruct user to inspect
517+
// build logs.
518+
status.fail("Error encountered while building graph. Inspect build logs.");
519+
ServerController.terminateInstances(ec2, graphBuildingInstances);
520+
return;
521+
}
522+
515523
status.update("Graph build is complete!", 40);
516524
// If only building graph, job is finished. Note: the graph building EC2 instance should automatically shut
517525
// itself down if this flag is turned on (happens in user data). We do not want to proceed with the rest of
@@ -522,13 +530,7 @@ private void replaceEC2Servers() {
522530
}
523531

524532
Persistence.deployments.replace(deployment.id, deployment);
525-
if (monitorInitialServerJob.status.error) {
526-
// If an error occurred while monitoring the initial server, fail this job and instruct user to inspect
527-
// build logs.
528-
status.fail("Error encountered while building graph. Inspect build logs.");
529-
ServerController.terminateInstances(ec2, graphBuildingInstances);
530-
return;
531-
}
533+
532534
// Check if a new image of the instance with the completed graph build should be created.
533535
if (otpServer.ec2Info.recreateBuildImage) {
534536
status.update("Creating build image", 42.5);

0 commit comments

Comments
 (0)