-
Notifications
You must be signed in to change notification settings - Fork 73
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
[Feature/extensions] Migrates Start Detector #837
[Feature/extensions] Migrates Start Detector #837
Conversation
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…tion Signed-off-by: Joshua Palis <jpalis@amazon.com>
…ction Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…g AnomalyDetectorJobTransportAction class to jacoco exclusions Signed-off-by: Joshua Palis <jpalis@amazon.com>
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 @@
## feature/extensions #837 +/- ##
========================================================
- Coverage 39.89% 34.92% -4.98%
+ Complexity 2111 1865 -246
========================================================
Files 297 298 +1
Lines 17113 17510 +397
Branches 1843 1857 +14
========================================================
- Hits 6827 6115 -712
- Misses 9799 10967 +1168
+ Partials 487 428 -59
Flags with carried forward coverage won't be shown. Click here to find out more.
|
… AD_JOB_TYPE to AnomalyDetectorExtension Signed-off-by: Joshua Palis <jpalis@amazon.com>
…omalyDetectorJobAction Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…eating NodeFilterer Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…bRunner. Modifies updateLatestFlagofOldTasksAndCreateNewTask() to use a blocking rest request instead of client.execute() Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…/ create components. Migrates start detector workflow invocations of opensearch actions with corresponding opensearchAsyncClient methods Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…aAsyncClient as part of create components to close later along with the sdkRestClient Signed-off-by: Joshua Palis <jpalis@amazon.com>
7aee890
to
e0e1bb0
Compare
…duler rather than the action name Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
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.
Great work with the migration and integrating job scheduler! Good to see the workflow.
src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/transport/ADJobRunnerTransportAction.java
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/transport/ADJobRunnerTransportAction.java
Outdated
Show resolved
Hide resolved
…tchAll Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
…ndex Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Joshua Palis <jpalis@amazon.com>
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 with some observations and an agreement about a rename that you can consider now or later when we re-branch and merge.
return ImmutableList | ||
.of(sdkRestClient, anomalyDetectionIndices, jvmService, adCircuitBreakerService, adTaskManager, adTaskCacheManager); | ||
.of( |
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.
Just a comment as I haven't checked. Ideally the order here and in code above defining these matches the AD Plugin, to minimize the diff.
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've followed it as closely as I could. There are some components that have not been implemented yet, since I havent needed them yet. But overall, the order in which the components are created and returned is the same as ADPlugin
Math.max(1, OpenSearchExecutors.allocatedProcessors(settings) / 2), | ||
TimeValue.timeValueMinutes(10), | ||
AD_THREAD_POOL_PREFIX + AD_THREAD_POOL_NAME | ||
)// , |
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.
(Style) Would really prefer block comment format-preserving comments here. (Start with /*-
and keep the indentation in the middle before the */
.
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.
Ill go ahead and fix this
AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX, | ||
false, | ||
ThrowingSupplierWrapper.throwingSupplierWrapper(AnomalyDetectionIndices::getAnomalyDetectorJobMappings) | ||
), |
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 complaint here, just pointing to the diff above as a reason we shouldn't be using //
comments on blocks of code :)
src/main/java/org/opensearch/ad/indices/AnomalyDetectionIndices.java
Outdated
Show resolved
Hide resolved
// } | ||
// | ||
// } | ||
/** |
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.
UGH, this diff!!!!
I don't even know what changed!
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
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.
Almost there. Few more nitpicks and questions
releaseLockRequest.addParameter(LockModel.LOCK_ID, lock.getLockId()); | ||
|
||
try { | ||
Response releaseLockResponse = client.performRequest(releaseLockRequest); |
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 performRequest
async?
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.
performRequest
is a blocking call. There is currently no async mechanism to send a rest call via the SDKRestClient.
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.
@joshpalis let's add async in SDK and use it here. This can be done in the next PR.
try { | ||
CompletableFuture<DeleteByQueryResponse> deleteResponse = sdkJavaAsyncClient.deleteByQuery(deleteRequest); | ||
DeleteByQueryResponse response = deleteResponse.orTimeout(10L, TimeUnit.SECONDS).get(); | ||
if (response.timedOut() || !response.failures().isEmpty()) { |
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 test this whenever we uncomment the tests and also can you create an issue on opensearch-java for getBulkFailures
?
logger.warn(BULK_FAILURE_LOG_MSG + " {}", detectorID); | ||
for (BulkIndexByScrollFailure bulkFailure : response.failures()) { | ||
logger.warn(bulkFailure); | ||
} |
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 is a little confusing to me. We have BulkIndexByScrollFailure
but old code has ScrollableHitSource
which is use for the scrollable results. @saratvemulapalli need some inputs here to verify the changes in this file
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.
@VachaShah just wanted to get your input on this. Please correct me if I am wrong, but as we discussed before, the DeleteByQueryResponse
failures for opensearch-java's OpenSearchAsyncClient
must be read from the list of BulkIndexByScrollFailure
and there are no corresponding types for the HighLevelRestClient's SearchFailure
and BulkFailure
.
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 for DeleteByQueryResponse
in the java-client, the failures need to be read from the list of BulkByIndexScrollFailures
.
src/main/java/org/opensearch/ad/transport/ADJobRunnerTransportAction.java
Show resolved
Hide resolved
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
Signed-off-by: Joshua Palis <jpalis@amazon.com>
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.
Looking for some inputs from @VachaShah! If any code change is required @joshpalis you can handle it in the next PR!
Description
Migrates the AnomalyDetectorJobTransportAction, RestAnomalyDetectorJobAction, and other supporting classes from plugin to extension.
This PR implements the following :
AnomalyDetectorJobTransportAction
/RestAnomalyDetectorJobAction
- which is used for both stop and start detectorADJobParameterTransportAction
/ADJobRunnerTransportAction
to facilitate job index entry parsing and job execution..opendistro-anomaly-detection-state
,.opendistro-anomaly-results
,.opendistro-anomaly-detector-job
,.opensearch-job-scheduler-job-details
, and.opendistro-job-scheduler-lock
At the state of this PR, when a job is executed, this will continue running in an infinite loop, as the job execution workflow ends when
AnomalyDetectorJobRunner.runAnomalyDetectionJob
is invoked, which is commented out and will be integrated with the SDK in this issue : opensearch-project/opensearch-sdk-java#626. This eventually calls theAnomalyResultAction
which indexes the anomaly result of the detector and releases the lock and thus ending the job. Subsequent attempts of Job Scheduler to execute the next run of the same Job will generate an anomaly result exception document due to a null lock, since the first execution has not yet released the lock. Indexing this anomaly result exception then instantiates the default anomaly result index.The full workflow of the communication between Job Scheduler and Anomaly Detection Extension can be seen here : opensearch-project/opensearch-sdk-java#427
Issues Resolved
opensearch-project/opensearch-sdk-java#383
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.