-
Notifications
You must be signed in to change notification settings - Fork 77
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
[Extensions] Create a proxy ScheduledJobRunner, ScheduledJobParser to invoke corresponding registered Job Detail actions #306
[Extensions] Create a proxy ScheduledJobRunner, ScheduledJobParser to invoke corresponding registered Job Detail actions #306
Conversation
…ameters nto compatible inputs for the ExtensionActionRequest. Completed initial proxy scheduled job parser implementation. Added ExtensionJobParameter class to deserialize ExtensionActionResponsebyte array into an object of type ScheduledJobParameter Signed-off-by: Joshua Palis <[email protected]>
…teable, created initial proxy ScheduledJobRunner, fixed failing tests Signed-off-by: Joshua Palis <[email protected]>
…equest, modified JobParameter/Runner request to implement writeable, refactored proxy object creation so that the requests are added to the ExtensionJobActionRequest, which in turn upcasts the request into an ExtensionActionRequest Signed-off-by: Joshua Palis <[email protected]>
…dded javadocs Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
…xtensions to validate prior to invoking an action Signed-off-by: Joshua Palis <[email protected]>
…onse to facilitate the response of extension actions Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
XContentBuilder builder = XContentFactory.jsonBuilder(); | ||
builder.copyCurrentStructure(jobParser); | ||
this.jobSource = BytesReference.bytes(builder); | ||
this.accessToken = accessToken; |
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 would leave the details of accessToken
to @dbwiddis.
My preference is to not care about security at this point and get the communication working and we can add security later. There might be lot more implications we have to consider like:
- How are we gating JS Rest APIs
- Who can modify a job parameter, job index (a.k.a any meta data) etc
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.
Agree the "details" will be implemented later but I think it's safe to put a placeholder String here for now as part of the "communication". We're doing the same thing with the Rest Handler communication with a placeholder string and eventual authentication integration based on it.
@@ -24,6 +29,19 @@ public JobDocVersion(long primaryTerm, long seqNo, long version) { | |||
this.version = version; | |||
} | |||
|
|||
public JobDocVersion(StreamInput in) throws IOException { |
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.
What is JobDocVersion, who uses this internally?
Why should an extension care about this internal implementation of JS?
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 JobDocVersion
represents the version of a particular job entry, which JobScheduler uses to determine whether or not a particular job entry is outdated, this can happen when a job configuration is updated by the plugin. The JobSweeper
maintains a map of jobs that it has "swept" (schedule/deschedule) which occurs every time a plugin indexes/updates another job to it's registered job index.
The reason why the JobDocVersion
is included as part of the request to extensions is because it is one of the parameters of ScheduledJobParser.parse(XcontentParser, docId, jobDocVersion)
.
While the Anomaly Detection implementation of the ScheduledJobParser
utilizes only the provided xContentParser
, I felt that it would be necessary to add support to transport both the docId
and also the JobDocVersion
as well, in case an extension required this information.
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 instance, ISM requires the jobDocVersion
here within their ScheduledJobParser
implementation
src/main/java/org/opensearch/jobscheduler/model/ExtensionJobParameter.java
Show resolved
Hide resolved
src/main/java/org/opensearch/jobscheduler/model/ExtensionJobParameter.java
Show resolved
Hide resolved
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
// no op | ||
return null; |
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.
This seems dangerous. Is there a better "empty builder" constant we can return here?
* @throws IOException if serialization fails | ||
* @return the byte array of the parameters | ||
*/ | ||
public static <T extends Writeable> byte[] convertParamsToBytes(T actionParams) throws IOException { |
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.
No issues with this method to produce a byte stream, but since this is effectively the same as creating a Writeable
object, why not just pass the actionParams
directly as a writeable object? The only benefit I see to this is that it allows for a more flexible signature (a byte array) but that loses the type safety of the individual elements of it, and introduces complications handling the different array lengths when it's deserialized.
* @throws IOException if serialization fails | ||
* @return the byte array of the parameters | ||
*/ | ||
public static <T extends Writeable> byte[] convertResponseToBytes(T actionResponse) throws IOException { |
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.
this duplicates the static method in ExtensionJobActionRequest
. Seems it could just be a static method on the Writeable
interface itself if it's that useful. Or at least at some common parent of ExtensionActionRequest
and ExtensionActionResponse
.
I'm still not convinced it has any benefit beyond the Writeable
interface that lets it be deserialized somewhere. Where is this byte array handled?
inProgressFuture.orTimeout(JobDetailsService.TIME_OUT_FOR_REQUEST, TimeUnit.SECONDS).join(); | ||
} catch (CompletionException e) { | ||
if (e.getCause() instanceof TimeoutException) { | ||
logger.info("Request timed out with an exception ", e); |
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 way this is handled, this will just log this and not throw an exception. You may not want "else" below this.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #306 +/- ##
============================================
- Coverage 31.17% 24.87% -6.31%
Complexity 66 66
============================================
Files 12 19 +7
Lines 773 969 +196
Branches 80 87 +7
============================================
Hits 241 241
- Misses 513 709 +196
Partials 19 19
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Joshua Palis <[email protected]>
… JobDocVersion, ExtensionJobParameter, ExtensionJobActionRequest, ExtensionJobActionResponse, JobRunner/JobParameter/Request/Response Signed-off-by: Joshua Palis <[email protected]>
…deserialization Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
This particular constructor has been made public here. Seems that checks are failing due to stale OS 3.0.0 artifacts, will re-run all failed jobs once a successful jenkins build has been made. |
Signed-off-by: Joshua Palis <[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.
"Approved with suggestions":
LGTM, a few questions and suggestions you may want to consider but I wouldn't hold up merging for them.
spi/src/main/java/org/opensearch/jobscheduler/spi/JobExecutionContext.java
Show resolved
Hide resolved
src/main/java/org/opensearch/jobscheduler/model/ExtensionJobParameter.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/jobscheduler/model/ExtensionJobParameter.java
Show resolved
Hide resolved
src/main/java/org/opensearch/jobscheduler/model/ExtensionJobParameter.java
Show resolved
Hide resolved
XContentBuilder builder = XContentFactory.jsonBuilder(); | ||
builder.copyCurrentStructure(jobParser); | ||
this.jobSource = BytesReference.bytes(builder); | ||
this.accessToken = accessToken; |
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.
Agree the "details" will be implemented later but I think it's safe to put a placeholder String here for now as part of the "communication". We're doing the same thing with the Rest Handler communication with a placeholder string and eventual authentication integration based on it.
src/main/java/org/opensearch/jobscheduler/transport/JobParameterResponse.java
Show resolved
Hide resolved
…itter values, added javadocs to ScheduleType enum and made this public Signed-off-by: Joshua Palis <[email protected]>
Signed-off-by: Joshua Palis <[email protected]>
…onCluster task. mixedClusterTask is still failing Signed-off-by: Joshua Palis <[email protected]>
…he extension job parameter entry within the registered job index, modifed the ExtensionJobParameter to null check the jitter value and setting this to 0.0 if null Signed-off-by: Joshua Palis <[email protected]>
…#382) * Communication mechanism for js (#289) * Job Details from Extension for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Commnunication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> * Communication Mechanism for JS Signed-off-by: Varun Jain <[email protected]> Signed-off-by: Varun Jain <[email protected]> * [Extensions] Synchronize opensearch-plugin-job-details with JobDetailsService map (#299) * Added JobDetailsService as an indexOperationListener to synchronize metadata index with internal job details m and indicesToListen set. Signed-off-by: Joshua Palis <[email protected]> * Changes indexToJobDetails to a ConcurrentMap, adds getter method for indexToJobDetails Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments, fixing log message Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments Signed-off-by: Joshua Palis <[email protected]> * Added test to updateIndexToJobDetails Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments, changing extensionId to extensionUniqueId Signed-off-by: Joshua Palis <[email protected]> * Addressing PR Comments : Updating Job Details index Name and mapping file to opensearch-job-scheduler-job-details Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments, enabling extensions to submit more than 1 job details entry to support extensions registering multiple types of jobs, updated all integration, multinode tests now that the rest response value is the document Id Signed-off-by: Joshua Palis <[email protected]> * Renaming TestHelper base URI name Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments, made multinode test request strings constant Signed-off-by: Joshua Palis <[email protected]> Signed-off-by: Joshua Palis <[email protected]> * [Extensions] Create a proxy ScheduledJobRunner, ScheduledJobParser to invoke corresponding registered Job Detail actions (#306) * Draft : Added JobParameterRequest to translate ScheduledJobParser parameters nto compatible inputs for the ExtensionActionRequest. Completed initial proxy scheduled job parser implementation. Added ExtensionJobParameter class to deserialize ExtensionActionResponsebyte array into an object of type ScheduledJobParameter Signed-off-by: Joshua Palis <[email protected]> * Added JobRunnerRequest, modified JobExecutionContext to implement writeable, created initial proxy ScheduledJobRunner, fixed failing tests Signed-off-by: Joshua Palis <[email protected]> * Added generic ExtensionJobActionRequest that extends ExtensionActionRequest, modified JobParameter/Runner request to implement writeable, refactored proxy object creation so that the requests are added to the ExtensionJobActionRequest, which in turn upcasts the request into an ExtensionActionRequest Signed-off-by: Joshua Palis <[email protected]> * Added byte array constructors for the JobRunner/Parameter requests, added javadocs Signed-off-by: Joshua Palis <[email protected]> * Fixing javadocs Signed-off-by: Joshua Palis <[email protected]> * Fixing javadocs Signed-off-by: Joshua Palis <[email protected]> * Added placeholder string for an eventual access token to be sent to extensions to validate prior to invoking an action Signed-off-by: Joshua Palis <[email protected]> * Added ExtensionJobActionResponse, JobParameterResponse, JobRunnerResponse to facilitate the response of extension actions Signed-off-by: Joshua Palis <[email protected]> * Fixing javadocs Signed-off-by: Joshua Palis <[email protected]> * Added JobRunnerResponse handling Signed-off-by: Joshua Palis <[email protected]> * Separating updateIndexToJobProviders into separate methods Signed-off-by: Joshua Palis <[email protected]> * Fixing javadocs Signed-off-by: Joshua Palis <[email protected]> * SpotlessApply Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments Signed-off-by: Joshua Palis <[email protected]> * Added tests for serialization/deserialization of JobExecutionContext, JobDocVersion, ExtensionJobParameter, ExtensionJobActionRequest, ExtensionJobActionResponse, JobRunner/JobParameter/Request/Response Signed-off-by: Joshua Palis <[email protected]> * Writing ExtensionActionRequest/Response to bytestream output to test deserialization Signed-off-by: Joshua Palis <[email protected]> * Fixing imports Signed-off-by: Joshua Palis <[email protected]> * Changing to extensionActionResponse constructor Signed-off-by: Joshua Palis <[email protected]> * Adding tests for updateIndexToJobProviders Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments, added getters for lock duration seconds and jitter values, added javadocs to ScheduleType enum and made this public Signed-off-by: Joshua Palis <[email protected]> * Removing Strings dependency from lock model to fix BWC tests Signed-off-by: Joshua Palis <[email protected]> * Fixes BWC fullRestartClusterTask, rollingUpgradeClusterTask, oldVersionCluster task. mixedClusterTask is still failing Signed-off-by: Joshua Palis <[email protected]> * Modified createProxyScheduledJobRunner to return the document Id of the extension job parameter entry within the registered job index, modifed the ExtensionJobParameter to null check the jitter value and setting this to 0.0 if null Signed-off-by: Joshua Palis <[email protected]> --------- Signed-off-by: Joshua Palis <[email protected]> * [Extensions] Exposes a GetLock REST API to enable extensions to acquire a lock model for their job execution (#311) * Added RestGetLockAction API, added AcquireLockRequest, enables extensions to retrieve a lock model object to run their Job Signed-off-by: Joshua Palis <[email protected]> * Adding Lock ID field to RestGetLockAction response Signed-off-by: Joshua Palis <[email protected]> * Added multi node integration tests for GetLockApi Signed-off-by: Joshua Palis <[email protected]> * Making lock service in RestGetLockAction private Signed-off-by: Joshua Palis <[email protected]> * Added Rest integration tests for RestGetLockAction Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments Signed-off-by: Joshua Palis <[email protected]> * Updating get lock rest path in tests Signed-off-by: Joshua Palis <[email protected]> * Addressing PR comments Signed-off-by: Joshua Palis <[email protected]> --------- Signed-off-by: Joshua Palis <[email protected]> * Communication Mechanism Work Item 6 Release lock api (#312) * Release lock API Signed-off-by: Varun Jain <[email protected]> * Release Lock API Signed-off-by: Varun Jain <[email protected]> * Release Lock API Signed-off-by: Varun Jain <[email protected]> * Release Lock API Signed-off-by: Varun Jain <[email protected]> * Reformatting Signed-off-by: Varun Jain <[email protected]> * Reformatting Signed-off-by: Varun Jain <[email protected]> * Reformatting Signed-off-by: Varun Jain <[email protected]> * Addressing Dan's Comments Signed-off-by: Varun Jain <[email protected]> * Addressing Dan's Comments Signed-off-by: Varun Jain <[email protected]> * Addressing Sarat's Comments Signed-off-by: Varun Jain <[email protected]> * Addressing Sarat's Comments Signed-off-by: Varun Jain <[email protected]> * Fixing test cases Signed-off-by: Varun Jain <[email protected]> * Fixing test cases Signed-off-by: Varun Jain <[email protected]> * Fixing ReleaseLocktestcase Signed-off-by: Varun Jain <[email protected]> * Fixing ReleaseLocktestcase Signed-off-by: Varun Jain <[email protected]> --------- Signed-off-by: Varun Jain <[email protected]> * Bumping BWC version to 2.7 and Fixing xcontent imports (#322) * [Extensions] Add all fields of LockModel to RestGetLockAction response (#342) * Modifies the RestGetLockAction response to include all fields of the lock model object, rather than the lock model object itself Signed-off-by: Joshua Palis <[email protected]> * Removing unused fields Signed-off-by: Joshua Palis <[email protected]> * reverting field removal Signed-off-by: Joshua Palis <[email protected]> * Adding lockID to back to response Signed-off-by: Joshua Palis <[email protected]> * Adding checks to multinode get lock rest integration tests to ensure that all response fields are populated Signed-off-by: Joshua Palis <[email protected]> * fixing lock time parsing Signed-off-by: Joshua Palis <[email protected]> * Adds a new Response class to house serde logic for RestGetLockAction response Signed-off-by: Joshua Palis <[email protected]> * Moving parser.nextToken() within AcquireLockResponse.parse() Signed-off-by: Joshua Palis <[email protected]> * Implementing toXContentObject for AcquireLockRequest Signed-off-by: Joshua Palis <[email protected]> * Moving AcquireLockResponse to transpor package Signed-off-by: Joshua Palis <[email protected]> --------- Signed-off-by: Joshua Palis <[email protected]> * Increasing JobDetailsService request timeoufrom 10 to 15, since the initial job detail registration request will initialize the job details metadata index, which takes some time (#346) Signed-off-by: Joshua Palis <[email protected]> * Fixes serde logic for proxy scheduled jobrunner/parser requests/responses (#349) Signed-off-by: Joshua Palis <[email protected]> * Fixes serde logic for JobParameterRequest/JobRunnerRequest. Removes extra trimming of request bytes for the streaminput constructor for the JobParameter/RunnerRequest, as this is already trimmed by the SDK prior to forwarding the actionrequest to the transport action (#351) Signed-off-by: Joshua Palis <[email protected]> * [Extensions] Makes JobRunner/Parameter/Request/Response classes extend from ActionRequest/Response (#352) * Replaces ExtensionActionRequest class name with the JobParameter/RunnerRequest fully qualified class names, modifes JobParameter/Runner/Request/Response classes to extend from ActionRequest/Response Signed-off-by: Joshua Palis <[email protected]> * Removes ExtensionJobActionResponse and fixes affected test classes Signed-off-by: Joshua Palis <[email protected]> * Fixing javadocs Signed-off-by: Joshua Palis <[email protected]> --------- Signed-off-by: Joshua Palis <[email protected]> * Consuming breaking changes from moving ExtensionActionRequest (#381) Signed-off-by: Sarat Vemulapalli <[email protected]> * spotless Signed-off-by: Joshua Palis <[email protected]> * Fixing apache imports for TestHelpers class Signed-off-by: Joshua Palis <[email protected]> * Modofies ODFERestTestCase to work with 2.x Signed-off-by: Joshua Palis <[email protected]> * Fixing wipeAllODFEIndices Signed-off-by: Joshua Palis <[email protected]> --------- Signed-off-by: Varun Jain <[email protected]> Signed-off-by: Joshua Palis <[email protected]> Signed-off-by: Sarat Vemulapalli <[email protected]> Co-authored-by: Varun Jain <[email protected]> Co-authored-by: Sarat Vemulapalli <[email protected]>
Description
Updates the
indexToJobProviders
with a proxyScheduledJobProvider
entry for an extension. Whenever aJobDetails
entry is indexed, the entry is pulled and registered within anindexToJobDetails
, updates theindicesToListen
set with the registered job index, creates a ProxyScheduledJobRunner
to invoke the extension'srunJob
implementation, and a ProxyScheduledJobParser
to invoke the extension'sparse
implementation.These actions are invoked via the
ExtensionProxyAction
, which is registered by theExtensionsManager
during bootstrap and delegates these requests to the originating extension.Issues Resolved
opensearch-project/opensearch-sdk-java#309
Check List
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.