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
Enforce 12 hour maxJobDuration #275
Closed
Closed
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
24d3f1a
enforce maxJobDuration
brendanmcfarland a9c0b10
test the throw
brendanmcfarland 7de5074
tests for invalid maxJobDurations
brendanmcfarland 5e91f79
clarify it's roughly 12 hours
brendanmcfarland bc6700a
bump package.json
brendanmcfarland File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -63,9 +63,10 @@ const dashboard = require(path.resolve(__dirname, 'dashboard.js')); | |
* number or a reference, i.e. `{"Ref": "..."}`. | ||
* @param {Boolean} [options.privileged=false] - give the container elevated | ||
* privileges on the host container instance | ||
* @param {Number|ref} [options.maxJobDuration] - the maximum number of seconds | ||
* @param {Number|ref} [options.maxJobDuration] - the number of seconds | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we say that the default is 12 hours? |
||
* before a worker will exit and SQS will once again make the message visible. | ||
* This parameter can be provided as either a number or a reference, i.e. `{"Ref": "..."}`. | ||
* The maximum value for this option is 43020 (roughly 12 hours). | ||
* @param {Number|ref} [options.messageRetention=1209600] - the number of seconds | ||
* that a message will exist in SQS until it is deleted. The default value is | ||
* the maximum time that SQS allows, 14 days. This parameter can be provided as | ||
|
@@ -107,13 +108,17 @@ module.exports = (options = {}) => { | |
if (!options[required]) throw new Error(`options.${required} is required`); | ||
}); | ||
|
||
if (options.maxJobDuration > 43020) throw new Error('options.maxJobDuration exceeds max value'); | ||
if (options.maxJobDuration < 1) throw new Error('options.maxJobDuration must be > 0'); | ||
|
||
|
||
options = Object.assign( | ||
{ | ||
prefix: 'Watchbot', | ||
watchbotVersion: 'v' + pkg.version, | ||
reservation: {}, | ||
env: {}, | ||
maxJobDuration: 0, | ||
maxJobDuration: 43020, | ||
messageRetention: 1209600, | ||
maxSize: 1, | ||
minSize: 0, | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm likely confused but it looks like if
maxJobDuration
is exceeded, the behavior is the same as when SQS hard limit of 12 hours is exceeded, because in both cases the message is returned to the queue, is that right?Or will a worker keep working when the 12-hour visibility timeout is breached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe the worker will keep working regardless of hitting the timeout. We could implement a hard cutoff, but that may or may not be desirable depending on the application context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah makes sense, thanks @rclark!