From 2d83d72fb76925acad07916012552f2ddb08d207 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 11 Sep 2024 23:36:54 +0000 Subject: [PATCH] Disable timeout params for deleteIndex API only for serverless (#646) Signed-off-by: Tomoyuki Morita (cherry picked from commit 06c8c66e47ccdf39100016eacb8610b79d83c423) Signed-off-by: github-actions[bot] --- .../core/storage/FlintOpenSearchClient.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java b/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java index affcd0e36..ef97f65ac 100644 --- a/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java +++ b/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java @@ -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; @@ -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()));