-
Notifications
You must be signed in to change notification settings - Fork 75
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] Increasing AD Extension Request timeout to 20 and fixes exception handling for Delete/Profile #916
Changes from 3 commits
13bcfbc
b15e84c
da221dd
aeedfbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,13 +56,15 @@ | |
import org.opensearch.ad.indices.ADIndex; | ||
import org.opensearch.ad.indices.AnomalyDetectionIndices; | ||
import org.opensearch.ad.model.Entity; | ||
import org.opensearch.ad.settings.AnomalyDetectorSettings; | ||
import org.opensearch.ad.util.ClientUtil; | ||
import org.opensearch.client.opensearch.OpenSearchAsyncClient; | ||
import org.opensearch.client.opensearch._types.BulkIndexByScrollFailure; | ||
import org.opensearch.client.opensearch._types.Conflicts; | ||
import org.opensearch.client.opensearch._types.ExpandWildcard; | ||
import org.opensearch.client.opensearch.core.DeleteByQueryRequest; | ||
import org.opensearch.client.opensearch.core.DeleteByQueryResponse; | ||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexNotFoundException; | ||
import org.opensearch.sdk.SDKClient.SDKRestClient; | ||
|
||
|
@@ -114,6 +116,7 @@ public class CheckpointDao { | |
|
||
// configuration | ||
private final String indexName; | ||
private final Settings settings; | ||
|
||
private Gson gson; | ||
private RandomCutForestMapper mapper; | ||
|
@@ -146,6 +149,7 @@ public class CheckpointDao { | |
* | ||
* @param client ES search client | ||
* @param sdkJavaAsyncClient OpenSearch Async Client | ||
* @param settings Environment Settings | ||
* @param clientUtil utility with ES client | ||
* @param indexName name of the index for model checkpoints | ||
* @param gson accessor to Gson functionality | ||
|
@@ -163,6 +167,7 @@ public class CheckpointDao { | |
public CheckpointDao( | ||
SDKRestClient client, | ||
OpenSearchAsyncClient sdkJavaAsyncClient, | ||
Settings settings, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm really iffy on adding a new parameter to an already-long list, but if we do so it should probably be at the end of the list, not in the middle. Also we could add an overload that delegates from the previous version to the new version with Settings.EMPTY to avoid having to change every single existing call. |
||
ClientUtil clientUtil, | ||
String indexName, | ||
Gson gson, | ||
|
@@ -179,6 +184,7 @@ public CheckpointDao( | |
) { | ||
this.client = client; | ||
this.sdkJavaAsyncClient = sdkJavaAsyncClient; | ||
this.settings = settings; | ||
this.clientUtil = clientUtil; | ||
this.indexName = indexName; | ||
this.gson = gson; | ||
|
@@ -452,7 +458,9 @@ public void deleteModelCheckpointByDetectorId(String detectorID) { | |
logger.info("Delete checkpoints of detector {}", detectorID); | ||
try { | ||
CompletableFuture<DeleteByQueryResponse> deleteResponse = sdkJavaAsyncClient.deleteByQuery(deleteRequest); | ||
DeleteByQueryResponse response = deleteResponse.orTimeout(10L, TimeUnit.SECONDS).get(); | ||
DeleteByQueryResponse response = deleteResponse | ||
.orTimeout(AnomalyDetectorSettings.REQUEST_TIMEOUT.get(settings).getMillis(), TimeUnit.MILLISECONDS) | ||
.get(); | ||
if (response.timedOut() || !response.failures().isEmpty()) { | ||
logFailure(response, detectorID); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,10 +54,11 @@ private LegacyOpenDistroAnomalyDetectorSettings() {} | |
Setting.Property.Deprecated | ||
); | ||
|
||
// TODO : Revert setting value back to 10 seconds once there is support for more targeted cluster state requests | ||
public static final Setting<TimeValue> REQUEST_TIMEOUT = Setting | ||
.positiveTimeSetting( | ||
"opendistro.anomaly_detection.request_timeout", | ||
TimeValue.timeValueSeconds(10), | ||
TimeValue.timeValueSeconds(20), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a TODO here to revert this back once we have support for cluster state? That's one of major reason for the timeout There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
Setting.Property.NodeScope, | ||
Setting.Property.Dynamic, | ||
Setting.Property.Deprecated | ||
|
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.
Similar comment here; we do have the settings at the end but can we just add an overloaded constructor that assumes empty settings if not passed so we don't have to rewrite existing constructor calls?