Skip to content
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

Migrate Delete Detector to SDK using SDKRestClient #374

Closed
1 task
Tracked by #5224
dbwiddis opened this issue Jan 29, 2023 · 2 comments
Closed
1 task
Tracked by #5224

Migrate Delete Detector to SDK using SDKRestClient #374

dbwiddis opened this issue Jan 29, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Jan 29, 2023

Is your feature request related to a problem?

Part of opensearch-project/OpenSearch#5224

What solution would you like?

Migrate the Delete Detector Rest API to Extensions SDK using SDKRestClient.

Use the implementation of #353 as a reference. Add new issues for any steps you skip.

Implement the following API endpoints:

  • DELETE _plugins/_anomaly_detection/detectors/<detectorId>
@owaiskazi19
Copy link
Member

owaiskazi19 commented Mar 14, 2023

Previously, the draft PR was blocked because of the actions coming as null on SDK which has been resolved.

Now, from the below error AD task is not being searched because .opendistro-anomaly-detection-state index is not created. The index gets created while starting the detector here. Keeping this issue on hold unless #383 is done.

18:05:32.063 [httpclient-dispatch-2] ERROR org.opensearch.ad.task.ADTaskManager - Failed to search AD task for detector ejOl3YYBSYtm-lGhtfp-
org.opensearch.OpenSearchStatusException: OpenSearch exception [type=index_not_found_exception, reason=no such index [.opendistro-anomaly-detection-state]]
        at org.opensearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:207) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
        at org.opensearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:2228) ~[opensearch-rest-high-level-client-3.0.0-SNAPSHOT.jar:?]
        at org.opensearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:2205) ~[opensearch-rest-high-level-client-3.0.0-SNAPSHOT.jar:?]
        at org.opensearch.client.RestHighLevelClient$1.onFailure(RestHighLevelClient.java:2116) [opensearch-rest-high-level-client-3.0.0-SNAPSHOT.jar:?]
        at org.opensearch.client.RestClient$FailureTrackingResponseListener.onDefinitiveFailure(RestClient.java:729) [opensearch-rest-client-3.0.0-SNAPSHOT.jar:?]
        at org.opensearch.client.RestClient$1.completed(RestClient.java:450) [opensearch-rest-client-3.0.0-SNAPSHOT.jar:?]
        at org.opensearch.client.RestClient$1.completed(RestClient.java:434) [opensearch-rest-client-3.0.0-SNAPSHOT.jar:?]
        at org.apache.hc.core5.concurrent.BasicFuture.completed(BasicFuture.java:123) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.concurrent.ComplexFuture.completed(ComplexFuture.java:79) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.client5.http.impl.async.InternalAbstractHttpAsyncClient$1$3$1.completed(InternalAbstractHttpAsyncClient.java:299) [httpclient5-5.1.4.jar:5.1.4]
        at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer$2.completed(AbstractAsyncResponseConsumer.java:108) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer.completed(AbstractBinAsyncEntityConsumer.java:84) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.nio.entity.AbstractBinDataConsumer.streamEnd(AbstractBinDataConsumer.java:81) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.nio.support.AbstractAsyncResponseConsumer.streamEnd(AbstractAsyncResponseConsumer.java:149) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.client5.http.impl.async.HttpAsyncMainClientExec$1.streamEnd(HttpAsyncMainClientExec.java:235) [httpclient5-5.1.4.jar:5.1.4]
        at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamHandler.dataEnd(ClientHttp1StreamHandler.java:280) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.impl.nio.ClientHttp1StreamDuplexer.dataEnd(ClientHttp1StreamDuplexer.java:366) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.impl.nio.AbstractHttp1StreamDuplexer.onInput(AbstractHttp1StreamDuplexer.java:335) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.impl.nio.AbstractHttp1IOEventHandler.inputReady(AbstractHttp1IOEventHandler.java:64) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.http.impl.nio.ClientHttp1IOEventHandler.inputReady(ClientHttp1IOEventHandler.java:41) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.InternalDataChannel.onIOEvent(InternalDataChannel.java:133) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.InternalChannel.handleIOEvent(InternalChannel.java:51) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.SingleCoreIOReactor.processEvents(SingleCoreIOReactor.java:178) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.SingleCoreIOReactor.doExecute(SingleCoreIOReactor.java:127) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.AbstractSingleCoreIOReactor.execute(AbstractSingleCoreIOReactor.java:85) [httpcore5-5.1.5.jar:5.1.5]
        at org.apache.hc.core5.reactor.IOReactorWorker.run(IOReactorWorker.java:44) [httpcore5-5.1.5.jar:5.1.5]
        at java.lang.Thread.run(Thread.java:832) [?:?]
        Suppressed: org.opensearch.client.ResponseException: method [POST], host [http://127.0.0.1:9200], URI [/.opendistro-anomaly-detection-state/_search?typed_keys=true&max_concurrent_shard_requests=5&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&search_type=query_then_fetch&batched_reduce_size=512&ccs_minimize_roundtrips=true], status line [HTTP/1.1 404 Not Found]
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [.opendistro-anomaly-detection-state]","index":".opendistro-anomaly-detection-state","resource.id":".opendistro-anomaly-detection-state","resource.type":"index_or_alias","index_uuid":"_na_"}],"type":"index_not_found_exception","reason":"no such index [.opendistro-anomaly-detection-state]","index":".opendistro-anomaly-detection-state","resource.id":".opendistro-anomaly-detection-state","resource.type":"index_or_alias","index_uuid":"_na_"},"status":404}

@owaiskazi19
Copy link
Member

Delete Detector worked with the correct response.
Tested with DELETE method
API: 127.0.0.1:9200/_extensions/_ad-extension/detectors/exLuTYcBzPWgaZWl_VLb

Response

{
    "_index": ".opendistro-anomaly-detectors",
    "_id": "LSXrTYcB70sQaKGvIW8c",
    "_version": 2,
    "result": "deleted",
    "forced_refresh": true,
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    },
    "_seq_no": 2,
    "_primary_term": 1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants