Skip to content

Commit

Permalink
Disable timeout params for deleteIndex API only for serverless (opens…
Browse files Browse the repository at this point in the history
…earch-project#646)

Signed-off-by: Tomoyuki Morita <[email protected]>
  • Loading branch information
ykmr1224 authored Sep 11, 2024
1 parent fd3f82f commit 06c8c66
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.opensearch.client.RequestOptions;
import org.opensearch.client.indices.CreateIndexRequest;
import org.opensearch.client.indices.GetIndexRequest;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.flint.common.metadata.FlintMetadata;
import org.opensearch.flint.core.FlintClient;
Expand Down Expand Up @@ -69,13 +70,26 @@ public void deleteIndex(String indexName) {
LOG.info("Deleting Flint index " + indexName);
String osIndexName = sanitizeIndexName(indexName);
try (IRestHighLevelClient client = createClient()) {
DeleteIndexRequest request = new DeleteIndexRequest(osIndexName);
DeleteIndexRequest request = disableTimeoutsForServerless(
new DeleteIndexRequest(osIndexName)
);
client.deleteIndex(request, RequestOptions.DEFAULT);
} catch (Exception e) {
throw new IllegalStateException("Failed to delete Flint index " + osIndexName, e);
}
}

/** OpenSearch Serverless does not accept timeout parameters for deleteIndex API */
private DeleteIndexRequest disableTimeoutsForServerless(DeleteIndexRequest deleteIndexRequest) {
if (FlintOptions.SERVICE_NAME_AOSS.equals(options.getServiceName())) {
return deleteIndexRequest
.clusterManagerNodeTimeout((TimeValue) null)
.timeout((TimeValue) null);
} else {
return deleteIndexRequest;
}
}

public FlintWriter createWriter(String indexName) {
LOG.info(String.format("Creating Flint index writer for %s, refresh_policy:%s, " +
"batch_bytes:%d", indexName, options.getRefreshPolicy(), options.getBatchBytes()));
Expand Down

0 comments on commit 06c8c66

Please sign in to comment.