Skip to content

Commit

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

(cherry picked from commit 06c8c66)

Signed-off-by: Tomoyuki Morita <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 997b583 commit d4ac1b7
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 d4ac1b7

Please sign in to comment.