-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Substituting fixed delays with cron expression #234
Conversation
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
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.
Thanks @VithikaS, really like the simplicity of this! Looks good so far.
|
||
protected void scheduleTask(Map<Event, Schedule> eventScheduleMap) { | ||
timer = new Timer(); | ||
timer.schedule(new ScheduleEvent().eventScheduleMap(eventScheduleMap), 100, 10000); |
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.
Should we make the delay configurable, and use a higher default value than 100
?
Generally I think we should avoid scheduling any tasks while the API server is starting up, but the duration of the startup will of course vary depending on available resources etc.
} catch (InvalidExpressionException invalidExpressionException) { | ||
LOGGER.error("Exception in parsing cron expression and creating schedule", invalidExpressionException); | ||
} |
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'd say we should just propagate the exception to the caller, or re-throw it as RuntimeException
. Ideally, if a cron expression is invalid, we'd want the API server to not even start.
task.cron.metrics.vulnerability=* 0/4 * * * | ||
task.cron.mirror.github=* 0/4 * * * | ||
task.cron.mirror.osv=* 0/4 * * * | ||
task.cron.mirror.nist=* 0/4 * * * | ||
task.cron.componentIdentification=* 0/6 * * * | ||
task.cron.ldapSync=* 0/6 * * * | ||
task.cron.vulndbSync=* 0/4 * * * | ||
task.cron.repoMetaAnalysis=* 0/8 * * * | ||
task.cron.vulnAnalysis=* 0/8 * * * | ||
task.cron.vulnScanCleanUp=* 0/8 * * * | ||
task.cron.fortify.ssc.sync=* 0/8 * * * | ||
task.cron.defectdojo.sync=* 0/8 * * * | ||
task.cron.kenna.sync=* 0/8 * * * | ||
task.cron.index.consistency.check=* 0/8 * * * |
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.
For the default values we should add comments to explain what they are, as cron expressions can be quite cryptic if you're not used to them. For example, for task.cron.metrics.portfolio
, add a comment saying Every 4 hours
.
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.
All good comments.. going to address all of them in next commit. Thanks for the review!
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
Signed-off-by: vithikashukla <[email protected]>
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.
lgtm
Description
Changed scheduling of tasks from using fixed delays to using cron expression.
This change will enable triggering of jobs on more calendar like events.
Addressed Issue
Part of work required to make api server highly available
DependencyTrack/hyades#375
Additional Details
Checklist