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

[Backport 0.5] Disable timeout params for deleteIndex API only for serverless #649

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading