-
Notifications
You must be signed in to change notification settings - Fork 21
[Package Signing] Make the Revalidate Certificate job initialize once per day #405
Conversation
The Job infrastructure calls the job's Init method on each invocation of the job loop. This caused the Revalidate job to load secrets repeatedly.
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.
To be honest, this seems like a hack around the job runner. With this change, the job is responsible for looping its code over and over again until it determines it has been running for too long and needs to initialize, which should be a responsibility of the job runner. Additionally, preventing config from being reloaded too frequently sounds like something that all jobs could benefit from.
I think a better change would be to add some sort of InitMinimumFrequencySeconds
config that is used by JsonConfigurationJob
or JobRunner
itself to determine whether or not it needs to re-initialize.
@scottbommarito I added |
7ffc46d
to
5e75c48
Compare
|
||
private static bool ShouldInitialize(int? reinitializeAfterSeconds, Stopwatch timeSinceInitialization) | ||
{ | ||
// If there is no wait time between reinitializations, always reinitialize. |
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.
nit: you can make this one big boolean return!
(note: I changed the comment on the second condition)
return
// If there is no wait time between reinitializations, always reinitialize.
!reinitializeAfterSeconds.HasValue ||
// A null time since last initialization indicates that the job hasn't been initialized yet.
timeSinceInitialization == null ||
// Otherwise, only reinitialize if the reinitialization threshold has been reached.
(timeSinceInitialization.Elapsed.TotalSeconds > reinitializeAfterSeconds.Value);
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 considered that as well, but I think that it's a little easier to grok as it is.
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.
Updated the comment with the comment you suggested.
57ded38
to
03622b0
Compare
1bedb7b
to
c4434fc
Compare
… per day (#405) The Job infrastructure used to call the job's `Init` method on each invocation of the job loop, which caused the Revalidate job to load secrets repeatedly. This change adds the option to have a minimum wait time in between a job's `Init` calls.
The Job infrastructure used to call the job's
Init
method on each invocation of the job loop, which caused the Revalidate job to load secrets repeatedly. This change adds the option to have a minimum wait time in between a job'sInit
calls.