-
Notifications
You must be signed in to change notification settings - Fork 94
Job History Service #814
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
Job History Service #814
Conversation
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (69.99%) is below the target coverage (75.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #814 +/- ##
==========================================
+ Coverage 69.80% 69.99% +0.18%
==========================================
Files 38 38
Lines 1729 1733 +4
Branches 156 156
==========================================
+ Hits 1207 1213 +6
+ Misses 431 430 -1
+ Partials 91 90 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Jeremy Dupras <[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.
Thank you @Jeremydupras . PR looks close. left few comments. Will take a second pass once all are addressed.
src/test/java/org/opensearch/jobscheduler/utils/JobDetailsServiceIT.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/StatusHistoryModel.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java
Outdated
Show resolved
Hide resolved
}, exception -> fail("Exception during update: " + exception.getMessage()))); | ||
}, exception -> fail("Exception during initial record: " + exception.getMessage()))); | ||
|
||
latch.await(15L, TimeUnit.SECONDS); |
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.
why are we awaiting in tests, that too with arbitrary values
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.
Test are based directly off of the Lock service IT tests. Allows the test time for the async operations.
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.
we should not await tests. You handle assertions in the listener block so that should cover the case.
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.
removed the await
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.
The historyService has asynchronous methods when writing to in Index. The Await ensures that the method finished before evaluating the result.
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
spi/src/main/java/org/opensearch/jobscheduler/spi/JobExecutionContext.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/JobExecutionContext.java
Outdated
Show resolved
Hide resolved
private final Instant startTime; | ||
private final Instant endTime; | ||
private final int status; | ||
private final long seqNo; |
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.
Do we need to keep track of seqNo
and primaryTerm
. I'd prefer to only keep references to the new logic being introduced and not keep track of these metadata fields.
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.
The current design adds to the history list when the lock is created and updates the entry when the lock in released. If the sequence number and primary term are not tracked the history service should be changed to append only.
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 don't think its necessary to track these, but I suppose it doesn't hurt either.
FYI I see that the usage is here in the LockService.
UpdateRequest updateRequest = new UpdateRequest().index(LOCK_INDEX_NAME)
.id(updateLock.getLockId())
.setIfSeqNo(updateLock.getSeqNo())
.setIfPrimaryTerm(updateLock.getPrimaryTerm())
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
.doc(updateLock.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS))
.fetchSource(true);
According to the javadoc, this is the purpose:
/**
* only perform this update request if the document's modification was assigned the given
* sequence number. Must be used in combination with {@link #setIfPrimaryTerm(long)}
*
* If the document last modification was assigned a different sequence number a
* {@link org.opensearch.index.engine.VersionConflictEngineException} will be thrown.
*/
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Outdated
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/LockService.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/jobscheduler/JobSchedulerSettings.java
Outdated
Show resolved
Hide resolved
Thank you for the pr @Jeremydupras ! This looks like it would be a nice feature to have and makes sense to introduce it behind a feature flag. There's a couple of comments I left that need to be addressed, but the pr mostly looks good. |
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[email protected]>
Signed-off-by: Jeremy Dupras <[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.
left small comments, looks good otherwise.
spi/src/main/java/org/opensearch/jobscheduler/spi/utils/JobHistoryService.java
Show resolved
Hide resolved
spi/src/main/java/org/opensearch/jobscheduler/spi/JobExecutionContext.java
Outdated
Show resolved
Hide resolved
ActionListener.wrap(success -> {}, listener::onFailure) | ||
); | ||
} | ||
updateLock(lockToRelease, ActionListener.wrap(releasedLock -> listener.onResponse(releasedLock != null), listener::onFailure)); |
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.
is the call on this line independent of the one on line 341?
asking because both are executed in async manner.
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, 341 updates the history index with an end time and success status code. 350 releases the lock from the job which updates the lock index to "released = true"
Signed-off-by: Jeremy Dupras <[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.
Nice work @Jeremydupras ! LGTM 🎊
Description
Creates a history index that records when a job acquires a lock to execute. Upon completion the record is updated with a completion time. The History service is built into the lock service and completely within jobScheduler.
Logic path
->Extension plugin tries to acquire lock
if the lock is acquired then there is a new record added to the index. If not the nothing is added.
->status codes within the record show if the job finished execution
->upon completion the Extension plugin releases the lock and the record is updated to show the job completed
Example of the index contents
Related Issues
Resolves #808
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.