-
Notifications
You must be signed in to change notification settings - Fork 52
Improve monitorable server job exception handling #331
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
Merged
landonreed
merged 23 commits into
dev
from
improve-monitorable-server-job-exception-handling
Aug 20, 2020
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
33d6e76
fix(deploy): better handle more exceptions in monitor server job
evansiroky be81ea6
fix(deploy): use fresh ec2 client and catch terminate instance except…
evansiroky f08b5e1
fix(deploy): use nonce to ensure integrity of otp-runner status file
evansiroky 9bfb521
test(deploy): make deterministic nonce values
evansiroky 660c9c6
fix(deploy): check for null nonce in status file
evansiroky 7503f0e
fix(deploy): properly check for null otp-runner nonce
evansiroky 004f6de
fix(deploy): correctly create longer-lasting AWS sessions
evansiroky 579719c
refactor(deploy): remove code that customized credential session time
evansiroky d8799af
test(FeedStore): add test to verify file name of temp GTFS file
landonreed 09fd9e4
fix(FeedStore): write temp GTFS files with .zip suffix
landonreed f6f020a
test(FeedStoreTest): add javadoc, clean up test
landonreed bdc3e6b
Merge pull request #334 from ibi-group/fix-tmp-gtfs-creation
landonreed cc83994
refactor(deploy): correct graph build timeout wait time
evansiroky 928b610
refactor(deploy): upload otp-runner manifest, build/router-config.jso…
evansiroky e20e306
Merge branch 'graph-build-image-job' into improve-monitorable-server-…
evansiroky 56083f7
Merge branch 'graph-build-image-job' into improve-monitorable-server-…
evansiroky e27b982
Merge branch 'graph-build-image-job' into improve-monitorable-server-…
evansiroky 35f4f04
Merge branch 'dev' into improve-monitorable-server-job-exception-hand…
evansiroky 6fe3bfd
refactor(deploy): make sure to exit deployjob after graph building in…
evansiroky 144defa
refactor: introduce TimeTracker class for tracking task timeouts
evansiroky 529401d
refactor: various improvements after code review
evansiroky 564df01
test: update snapshots
evansiroky 6223b9b
refactor: fix typo
landonreed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
265 changes: 200 additions & 65 deletions
265
src/main/java/com/conveyal/datatools/manager/jobs/DeployJob.java
Large diffs are not rendered by default.
Oops, something went wrong.
162 changes: 105 additions & 57 deletions
162
src/main/java/com/conveyal/datatools/manager/jobs/MonitorServerStatusJob.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/conveyal/datatools/manager/utils/TimeTracker.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.conveyal.datatools.manager.utils; | ||
|
|
||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| /** | ||
| * A helper class to track whether a task has timed out. | ||
| */ | ||
| public class TimeTracker { | ||
| private final long maxEndTime; | ||
| private final long startTime = System.currentTimeMillis(); | ||
|
|
||
| /** | ||
| * @param maxDuration The maximum duration that this task should take. | ||
| * @param timeUnit the unit of time that the duration is in | ||
| */ | ||
| public TimeTracker(long maxDuration, TimeUnit timeUnit) { | ||
| maxEndTime = startTime + timeUnit.toMillis(maxDuration); | ||
| } | ||
|
|
||
|
|
||
| public boolean hasTimedOut() { | ||
| return System.currentTimeMillis() > maxEndTime; | ||
| } | ||
|
|
||
| public long elapsedSeconds() { | ||
| return (System.currentTimeMillis() - startTime) / 1000; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/com/conveyal/datatools/manager/persistence/FeedStoreTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package com.conveyal.datatools.manager.persistence; | ||
|
|
||
| import com.conveyal.datatools.DatatoolsTest; | ||
| import com.conveyal.datatools.UnitTest; | ||
| import com.conveyal.datatools.manager.models.FeedVersion; | ||
| import org.junit.Assert; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Test; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import java.io.File; | ||
| import java.io.FileInputStream; | ||
| import java.io.IOException; | ||
|
|
||
| import static com.conveyal.datatools.TestUtils.getGtfsResourcePath; | ||
|
|
||
| public class FeedStoreTest extends UnitTest { | ||
| private static final Logger LOG = LoggerFactory.getLogger(FeedStoreTest.class); | ||
|
|
||
| @BeforeClass | ||
| public static void setUp() throws Exception { | ||
| DatatoolsTest.setUp(); | ||
| LOG.info("{} setup", FeedStoreTest.class.getSimpleName()); | ||
| } | ||
|
|
||
| /** | ||
| * Verify that {@link FeedStore} will write a temp file with the input file name. | ||
| */ | ||
| @Test | ||
| public void canCreateTempGtfsFile() throws IOException { | ||
| final String gtfsFileName = "gtfs.zip"; | ||
| File gtfsFile = new File(getGtfsResourcePath("bart_new.zip")); | ||
| FileInputStream fileInputStream = new FileInputStream(gtfsFile); | ||
| File tempFile = FeedVersion.feedStore.createTempFile(gtfsFileName, fileInputStream); | ||
| LOG.info("Feed store wrote temp file to: {}", tempFile.getAbsolutePath()); | ||
| Assert.assertEquals(tempFile.getName(), gtfsFileName); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeGraphBuildUserDataScript-0.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| "#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\necho $'{\"buildConfigJSON\":\"{ \\\\\\\"hello\\\\\\\": \\\\\\\"th\\\\ne\\'r\\\\te\\\\\\\" }\",\"buildGraph\":true,\"graphObjUrl\":\"s3://datatools-dev/test-deploy/Graph.obj\",\"graphsFolder\":\"/var/otp/graphs\",\"jarFile\":\"/opt/otp/otp-latest-trimet-dev\",\"jarUrl\":\"https://opentripplanner-builds.s3.amazonaws.com/otp-latest-trimet-dev.jar\",\"otpRunnerLogFile\":\"/var/log/otp-runner.log\",\"prefixLogUploadsWithInstanceId\":true,\"routerConfigJSON\":\"{ \\\\\\\"hi\\\\\\\": \\\\\\\"th\\\\ne\\'r\\\\te\\\\\\\" }\",\"runServer\":true,\"s3UploadPath\":\"s3://datatools-dev/test-deploy\",\"serverStartupTimeoutSeconds\":3300,\"statusFileLocation\":\"/usr/share/nginx/client/status.json\",\"uploadGraphBuildLogs\":true,\"uploadGraphBuildReport\":true,\"uploadGraph\":true,\"uploadOtpRunnerLogs\":true,\"uploadServerStartupLogs\":true}' > /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git\notp-runner /var/otp/otp-runner-manifest.json" | ||
| "#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-graph-build-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" |
2 changes: 1 addition & 1 deletion
2
.../com/conveyal/datatools/manager/jobs/DeployJobTest/canMakeServerOnlyUserDataScript-0.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| "#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\necho $'{\"buildGraph\":false,\"graphObjUrl\":\"s3://datatools-dev/test-deploy/Graph.obj\",\"graphsFolder\":\"/var/otp/graphs\",\"jarFile\":\"/opt/otp/otp-latest-trimet-dev\",\"jarUrl\":\"https://opentripplanner-builds.s3.amazonaws.com/otp-latest-trimet-dev.jar\",\"otpRunnerLogFile\":\"/var/log/otp-runner.log\",\"prefixLogUploadsWithInstanceId\":true,\"routerConfigJSON\":\"{ \\\\\\\"hi\\\\\\\": \\\\\\\"th\\\\ne\\'r\\\\te\\\\\\\" }\",\"runServer\":true,\"s3UploadPath\":\"s3://datatools-dev/test-deploy\",\"serverStartupTimeoutSeconds\":3300,\"statusFileLocation\":\"/usr/share/nginx/client/status.json\",\"uploadGraphBuildLogs\":false,\"uploadGraphBuildReport\":false,\"uploadGraph\":false,\"uploadOtpRunnerLogs\":true,\"uploadServerStartupLogs\":true}' > /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git\notp-runner /var/otp/otp-runner-manifest.json" | ||
| "#!/bin/bash\nexport PATH=\"$PATH:/home/ubuntu/.yarn/bin\"\nexport PATH=\"$PATH:/home/ubuntu/.nvm/versions/node/v12.16.3/bin\"\nrm /usr/share/nginx/client/status.json || echo '' > /dev/null\nrm /var/otp/otp-runner-manifest.json || echo '' > /dev/null\nrm /opt/otp/otp-latest-trimet-dev || echo '' > /dev/null\nrm /var/log/otp-runner.log || echo '' > /dev/null\nrm /var/log/otp-build.log || echo '' > /dev/null\nrm /var/log/otp-server.log || echo '' > /dev/null\naws s3 cp s3://datatools-dev/test-deploy/otp-runner-server-manifest.json /var/otp/otp-runner-manifest.json\nyarn global add https://github.com/ibi-group/otp-runner.git#master\notp-runner /var/otp/otp-runner-manifest.json" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.