Skip to content

Commit

Permalink
Deprecate ignore_throttled parameter (#77479)
Browse files Browse the repository at this point in the history
Frozen indices are deprecated, which will make ignore_throttled obsolete.

Some changes to HLRC  HLRC and related tests were required in order to deprecate ignore_throttled parameter:
* Change HLRC request classes to set indices options initial value to null.
    This avoids sending the ignore_throttled parameter (and other indices options parameters)
    and therefore avoids the depracation warning header in the response. All these
    request classes had the indices options set to what is the defaukt in the corresponding
    action request class. So sending these indices options params was a noop, which is the same
    as not sending indices options parameters, which is what this change does.
* For transport action request classes that are reused in the HLRC as request class,
    change the corresponding hlrc request converter to only send indices options params
    if the indices options are different than what the default is.
* For tests that use a non default indices options, allow 'ignore_throttled is deprecated'
    warning.

Other changes:
* A number of tests have been changed to allowed warning header for deprecated ignore_throttled parameter.
* Some rest v7 compat yaml tests are temporary muted, but will be unmuted once this
    change has been backported.

Relates to #70192
  • Loading branch information
martijnvg authored Sep 16, 2021
1 parent 6e2e6c9 commit ff9f2a2
Show file tree
Hide file tree
Showing 49 changed files with 328 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.client.RequestConverters.Params;
import org.elasticsearch.client.asyncsearch.DeleteAsyncSearchRequest;
import org.elasticsearch.client.asyncsearch.GetAsyncSearchRequest;
Expand Down Expand Up @@ -53,7 +54,9 @@ static void addSearchRequestParams(Params params, SubmitAsyncSearchRequest reque
params.putParam(RestSearchAction.TYPED_KEYS_PARAM, "true");
params.withRouting(request.getRouting());
params.withPreference(request.getPreference());
params.withIndicesOptions(request.getIndicesOptions());
if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(request.getIndicesOptions()) == false) {
params.withIndicesOptions(request.getIndicesOptions());
}
params.withSearchType(request.getSearchType().name().toLowerCase(Locale.ROOT));
params.withMaxConcurrentShardRequests(request.getMaxConcurrentShardRequests());
if (request.getRequestCache() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
import org.elasticsearch.action.support.broadcast.BroadcastRequest;
import org.elasticsearch.client.indices.AnalyzeRequest;
import org.elasticsearch.client.indices.CloseIndexRequest;
import org.elasticsearch.client.indices.CreateDataStreamRequest;
Expand Down Expand Up @@ -100,7 +101,9 @@ static Request deleteIndex(DeleteIndexRequest deleteIndexRequest) {
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(deleteIndexRequest.timeout());
parameters.withMasterTimeout(deleteIndexRequest.masterNodeTimeout());
parameters.withIndicesOptions(deleteIndexRequest.indicesOptions());
if (DeleteIndexRequest.DEFAULT_INDICES_OPTIONS.equals(deleteIndexRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(deleteIndexRequest.indicesOptions());
}
request.addParameters(parameters.asMap());
return request;
}
Expand All @@ -113,7 +116,9 @@ static Request openIndex(OpenIndexRequest openIndexRequest) {
parameters.withTimeout(openIndexRequest.timeout());
parameters.withMasterTimeout(openIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(openIndexRequest.waitForActiveShards());
parameters.withIndicesOptions(openIndexRequest.indicesOptions());
if (OpenIndexRequest.DEFAULT_INDICES_OPTIONS.equals(openIndexRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(openIndexRequest.indicesOptions());
}
request.addParameters(parameters.asMap());
return request;
}
Expand All @@ -125,7 +130,9 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(closeIndexRequest.timeout());
parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout());
parameters.withIndicesOptions(closeIndexRequest.indicesOptions());
if (CloseIndexRequest.DEFAULT_INDICES_OPTIONS.equals(closeIndexRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(closeIndexRequest.indicesOptions());
}
parameters.withWaitForActiveShards(closeIndexRequest.waitForActiveShards());
request.addParameters(parameters.asMap());
return request;
Expand Down Expand Up @@ -163,7 +170,9 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(putMappingRequest.timeout());
parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout());
parameters.withIndicesOptions(putMappingRequest.indicesOptions());
if (PutMappingRequest.DEFAULT_INDICES_OPTIONS.equals(putMappingRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(putMappingRequest.indicesOptions());
}
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand Down Expand Up @@ -207,7 +216,9 @@ static Request refresh(RefreshRequest refreshRequest) {
Request request = new Request(HttpPost.METHOD_NAME, RequestConverters.endpoint(indices, "_refresh"));

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(refreshRequest.indicesOptions());
if (BroadcastRequest.DEFAULT_INDICES_OPTIONS.equals(refreshRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(refreshRequest.indicesOptions());
}
request.addParameters(parameters.asMap());
return request;
}
Expand All @@ -217,7 +228,9 @@ static Request flush(FlushRequest flushRequest) {
Request request = new Request(HttpPost.METHOD_NAME, RequestConverters.endpoint(indices, "_flush"));

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(flushRequest.indicesOptions());
if (BroadcastRequest.DEFAULT_INDICES_OPTIONS.equals(flushRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(flushRequest.indicesOptions());
}
parameters.putParam("wait_if_ongoing", Boolean.toString(flushRequest.waitIfOngoing()));
parameters.putParam("force", Boolean.toString(flushRequest.force()));
request.addParameters(parameters.asMap());
Expand All @@ -229,7 +242,9 @@ static Request forceMerge(ForceMergeRequest forceMergeRequest) {
Request request = new Request(HttpPost.METHOD_NAME, RequestConverters.endpoint(indices, "_forcemerge"));

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(forceMergeRequest.indicesOptions());
if (BroadcastRequest.DEFAULT_INDICES_OPTIONS.equals(forceMergeRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(forceMergeRequest.indicesOptions());
}
parameters.putParam("max_num_segments", Integer.toString(forceMergeRequest.maxNumSegments()));
parameters.putParam("only_expunge_deletes", Boolean.toString(forceMergeRequest.onlyExpungeDeletes()));
parameters.putParam("flush", Boolean.toString(forceMergeRequest.flush()));
Expand All @@ -242,7 +257,9 @@ static Request clearCache(ClearIndicesCacheRequest clearIndicesCacheRequest) {
Request request = new Request(HttpPost.METHOD_NAME, RequestConverters.endpoint(indices, "_cache/clear"));

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(clearIndicesCacheRequest.indicesOptions());
if (BroadcastRequest.DEFAULT_INDICES_OPTIONS.equals(clearIndicesCacheRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(clearIndicesCacheRequest.indicesOptions());
}
parameters.putParam("query", Boolean.toString(clearIndicesCacheRequest.queryCache()));
parameters.putParam("fielddata", Boolean.toString(clearIndicesCacheRequest.fieldDataCache()));
parameters.putParam("request", Boolean.toString(clearIndicesCacheRequest.requestCache()));
Expand All @@ -262,7 +279,9 @@ static Request existsAlias(GetAliasesRequest getAliasesRequest) {
Request request = new Request(HttpHead.METHOD_NAME, RequestConverters.endpoint(indices, "_alias", aliases));

RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(getAliasesRequest.indicesOptions());
if (GetAliasesRequest.DEFAULT_INDICES_OPTIONS.equals(getAliasesRequest.indicesOptions()) == false) {
params.withIndicesOptions(getAliasesRequest.indicesOptions());
}
params.withLocal(getAliasesRequest.local());
request.addParameters(params.asMap());
return request;
Expand Down Expand Up @@ -363,7 +382,9 @@ static Request getSettings(GetSettingsRequest getSettingsRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(getSettingsRequest.indicesOptions());
if (GetSettingsRequest.DEFAULT_INDICES_OPTIONS.equals(getSettingsRequest.indicesOptions()) == false) {
params.withIndicesOptions(getSettingsRequest.indicesOptions());
}
params.withLocal(getSettingsRequest.local());
params.withIncludeDefaults(getSettingsRequest.includeDefaults());
params.withMasterTimeout(getSettingsRequest.masterNodeTimeout());
Expand All @@ -378,7 +399,9 @@ static Request getIndex(GetIndexRequest getIndexRequest) {
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(getIndexRequest.indicesOptions());
if (GetIndexRequest.DEFAULT_INDICES_OPTIONS.equals(getIndexRequest.indicesOptions()) == false) {
params.withIndicesOptions(getIndexRequest.indicesOptions());
}
params.withLocal(getIndexRequest.local());
params.withIncludeDefaults(getIndexRequest.includeDefaults());
params.withHuman(getIndexRequest.humanReadable());
Expand All @@ -397,7 +420,9 @@ static Request indicesExist(GetIndexRequest getIndexRequest) {
RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(getIndexRequest.local());
params.withHuman(getIndexRequest.humanReadable());
params.withIndicesOptions(getIndexRequest.indicesOptions());
if (GetIndexRequest.DEFAULT_INDICES_OPTIONS.equals(getIndexRequest.indicesOptions()) == false) {
params.withIndicesOptions(getIndexRequest.indicesOptions());
}
params.withIncludeDefaults(getIndexRequest.includeDefaults());
request.addParameters(params.asMap());
return request;
Expand All @@ -410,7 +435,9 @@ static Request indexPutSettings(UpdateSettingsRequest updateSettingsRequest) thr
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withTimeout(updateSettingsRequest.timeout());
parameters.withMasterTimeout(updateSettingsRequest.masterNodeTimeout());
parameters.withIndicesOptions(updateSettingsRequest.indicesOptions());
if (UpdateSettingsRequest.DEFAULT_INDICES_OPTIONS.equals(updateSettingsRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(updateSettingsRequest.indicesOptions());
}
parameters.withPreserveExisting(updateSettingsRequest.isPreserveExisting());
request.addParameters(parameters.asMap());
request.setEntity(RequestConverters.createEntity(updateSettingsRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
Expand Down Expand Up @@ -477,7 +504,9 @@ static Request validateQuery(ValidateQueryRequest validateQueryRequest) throws I
String endpoint = RequestConverters.endpoint(indices, "_validate/query");
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(validateQueryRequest.indicesOptions());
if (ValidateQueryRequest.DEFAULT_INDICES_OPTIONS.equals(validateQueryRequest.indicesOptions()) == false) {
params.withIndicesOptions(validateQueryRequest.indicesOptions());
}
params.putParam("explain", Boolean.toString(validateQueryRequest.explain()));
params.putParam("all_shards", Boolean.toString(validateQueryRequest.allShards()));
params.putParam("rewrite", Boolean.toString(validateQueryRequest.rewrite()));
Expand All @@ -492,7 +521,9 @@ static Request getAlias(GetAliasesRequest getAliasesRequest) {
String endpoint = RequestConverters.endpoint(indices, "_alias", aliases);
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(getAliasesRequest.indicesOptions());
if (GetAliasesRequest.DEFAULT_INDICES_OPTIONS.equals(getAliasesRequest.indicesOptions()) == false) {
params.withIndicesOptions(getAliasesRequest.indicesOptions());
}
params.withLocal(getAliasesRequest.local());
request.addParameters(params.asMap());
return request;
Expand Down Expand Up @@ -610,7 +641,9 @@ static Request reloadAnalyzers(ReloadAnalyzersRequest reloadAnalyzersRequest) {
String endpoint = RequestConverters.endpoint(reloadAnalyzersRequest.getIndices(), "_reload_search_analyzers");
Request request = new Request(HttpPost.METHOD_NAME, endpoint);
RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(reloadAnalyzersRequest.indicesOptions());
if (ReloadAnalyzersRequest.DEFAULT_INDICES_OPTIONS.equals(reloadAnalyzersRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(reloadAnalyzersRequest.indicesOptions());
}
request.addParameters(parameters.asMap());
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ static void addSearchRequestParams(Params params, SearchRequest searchRequest) {
params.putParam(RestSearchAction.TYPED_KEYS_PARAM, "true");
params.withRouting(searchRequest.routing());
params.withPreference(searchRequest.preference());
params.withIndicesOptions(searchRequest.indicesOptions());
if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(searchRequest.indicesOptions()) == false) {
params.withIndicesOptions(searchRequest.indicesOptions());
}
params.withSearchType(searchRequest.searchType().name().toLowerCase(Locale.ROOT));
if (searchRequest.isCcsMinimizeRoundtrips() != SearchRequest.defaultCcsMinimizeRoundtrips(searchRequest)) {
params.putParam("ccs_minimize_roundtrips", Boolean.toString(searchRequest.isCcsMinimizeRoundtrips()));
Expand Down Expand Up @@ -437,7 +439,9 @@ static Request clearScroll(ClearScrollRequest clearScrollRequest) throws IOExcep
static Request openPointInTime(OpenPointInTimeRequest openRequest) {
Request request = new Request(HttpPost.METHOD_NAME, endpoint(openRequest.indices(), "_pit"));
Params params = new Params();
params.withIndicesOptions(openRequest.indicesOptions());
if (OpenPointInTimeRequest.DEFAULT_INDICES_OPTIONS.equals(openRequest.indicesOptions()) == false) {
params.withIndicesOptions(openRequest.indicesOptions());
}
params.withRouting(openRequest.routing());
params.withPreference(openRequest.preference());
params.putParam("keep_alive", openRequest.keepAlive());
Expand Down Expand Up @@ -539,7 +543,9 @@ static Request fieldCaps(FieldCapabilitiesRequest fieldCapabilitiesRequest) thro

Params params = new Params();
params.withFields(fieldCapabilitiesRequest.fields());
params.withIndicesOptions(fieldCapabilitiesRequest.indicesOptions());
if (FieldCapabilitiesRequest.DEFAULT_INDICES_OPTIONS.equals(fieldCapabilitiesRequest.indicesOptions()) == false) {
params.withIndicesOptions(fieldCapabilitiesRequest.indicesOptions());
}
request.addParameters(params.asMap());
if (fieldCapabilitiesRequest.indexFilter() != null) {
request.setEntity(createEntity(fieldCapabilitiesRequest, REQUEST_BODY_CONTENT_TYPE));
Expand All @@ -551,7 +557,9 @@ static Request rankEval(RankEvalRequest rankEvalRequest) throws IOException {
Request request = new Request(HttpGet.METHOD_NAME, endpoint(rankEvalRequest.indices(), Strings.EMPTY_ARRAY, "_rank_eval"));

Params params = new Params();
params.withIndicesOptions(rankEvalRequest.indicesOptions());
if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(rankEvalRequest.indicesOptions()) == false) {
params.withIndicesOptions(rankEvalRequest.indicesOptions());
}
params.putParam("search_type", rankEvalRequest.searchType().name().toLowerCase(Locale.ROOT));
request.addParameters(params.asMap());
request.setEntity(createEntity(rankEvalRequest.getRankEvalSpec(), REQUEST_BODY_CONTENT_TYPE));
Expand Down Expand Up @@ -613,9 +621,13 @@ private static Request prepareDeleteByQueryRequest(DeleteByQueryRequest deleteBy
.withTimeout(deleteByQueryRequest.getTimeout())
.withWaitForActiveShards(deleteByQueryRequest.getWaitForActiveShards())
.withRequestsPerSecond(deleteByQueryRequest.getRequestsPerSecond())
.withIndicesOptions(deleteByQueryRequest.indicesOptions())
.withWaitForCompletion(waitForCompletion)
.withSlices(deleteByQueryRequest.getSlices());

if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(deleteByQueryRequest.indicesOptions()) == false) {
params = params.withIndicesOptions(deleteByQueryRequest.indicesOptions());
}

if (deleteByQueryRequest.isAbortOnVersionConflict() == false) {
params.putParam("conflicts", "proceed");
}
Expand Down Expand Up @@ -644,9 +656,11 @@ static Request prepareUpdateByQueryRequest(UpdateByQueryRequest updateByQueryReq
.withTimeout(updateByQueryRequest.getTimeout())
.withWaitForActiveShards(updateByQueryRequest.getWaitForActiveShards())
.withRequestsPerSecond(updateByQueryRequest.getRequestsPerSecond())
.withIndicesOptions(updateByQueryRequest.indicesOptions())
.withWaitForCompletion(waitForCompletion)
.withSlices(updateByQueryRequest.getSlices());
if (SearchRequest.DEFAULT_INDICES_OPTIONS.equals(updateByQueryRequest.indicesOptions()) == false) {
params = params.withIndicesOptions(updateByQueryRequest.indicesOptions());
}
if (updateByQueryRequest.isAbortOnVersionConflict() == false) {
params.putParam("conflicts", "proceed");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import java.util.Arrays;
import java.util.Objects;

import static org.elasticsearch.action.search.SearchRequest.DEFAULT_INDICES_OPTIONS;

/**
* Encapsulates a request to _count API against one, several or all indices.
*/
Expand All @@ -33,7 +31,7 @@ public final class CountRequest implements Validatable, ToXContentObject {
private String routing;
private String preference;
private QueryBuilder query;
private IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS;
private IndicesOptions indicesOptions;
private int terminateAfter = SearchContext.DEFAULT_TERMINATE_AFTER;
private Float minScore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
public class EqlSearchRequest implements Validatable, ToXContentObject {

private String[] indices;
private IndicesOptions indicesOptions = IndicesOptions.fromOptions(true, true, true, false);
private IndicesOptions indicesOptions;

private QueryBuilder filter = null;
private String timestampField = "@timestamp";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class ExplainLifecycleRequest extends TimedRequest {

private final String[] indices;
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
private IndicesOptions indicesOptions;

public ExplainLifecycleRequest(String... indices) {
if (indices.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class RemoveIndexLifecyclePolicyRequest extends TimedRequest {
private final IndicesOptions indicesOptions;

public RemoveIndexLifecyclePolicyRequest(List<String> indices) {
this(indices, IndicesOptions.strictExpandOpen());
this.indices = Objects.requireNonNull(indices);
this.indicesOptions = null;
}

public RemoveIndexLifecyclePolicyRequest(List<String> indices, IndicesOptions indicesOptions) {
Expand Down
Loading

0 comments on commit ff9f2a2

Please sign in to comment.