Skip to content

Commit

Permalink
Deprecate ignore_throttled parameter (#77864)
Browse files Browse the repository at this point in the history
* Deprecate ignore_throttled parameter

Backporting #77479 to 7.x branch.

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

* adjust to 7.x reality

* adjust to 7.x reality (2)

* adjust 7.x request converters

* more 7.x adjustments
  • Loading branch information
martijnvg committed Sep 16, 2021
1 parent 303a7b9 commit 704752b
Show file tree
Hide file tree
Showing 50 changed files with 372 additions and 157 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 @@ -27,7 +27,9 @@
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.action.support.ActiveShardCount;
import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
import org.elasticsearch.client.indices.AnalyzeRequest;
import org.elasticsearch.client.indices.CloseIndexRequest;
import org.elasticsearch.client.indices.CreateDataStreamRequest;
Expand Down Expand Up @@ -104,7 +106,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 @@ -117,7 +121,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 @@ -129,7 +135,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());
}

final ActiveShardCount activeShardCount = closeIndexRequest.waitForActiveShards();
if (activeShardCount == ActiveShardCount.DEFAULT) {
Expand Down Expand Up @@ -188,7 +196,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 @@ -239,7 +249,9 @@ static Request getMappings(org.elasticsearch.action.admin.indices.mapping.get.Ge

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
if (ClusterInfoRequest.DEFAULT_INDICES_OPTIONS.equals(getMappingsRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
}
parameters.withLocal(getMappingsRequest.local());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
request.addParameters(parameters.asMap());
Expand Down Expand Up @@ -280,7 +292,10 @@ static Request getFieldMapping(org.elasticsearch.action.admin.indices.mapping.ge
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params parameters = new RequestConverters.Params();
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
if (org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsRequest.DEFAULT_INDICES_OPTIONS.equals(
getFieldMappingsRequest.indicesOptions()) == false) {
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
}
parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults());
parameters.withLocal(getFieldMappingsRequest.local());
parameters.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
Expand All @@ -293,7 +308,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 @@ -303,7 +320,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 @@ -324,7 +343,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 @@ -337,7 +358,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 @@ -357,7 +380,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 @@ -477,7 +502,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 @@ -497,7 +524,9 @@ static Request getIndex(org.elasticsearch.action.admin.indices.get.GetIndexReque
Request request = new Request(HttpGet.METHOD_NAME, endpoint);

RequestConverters.Params params = new RequestConverters.Params();
params.withIndicesOptions(getIndexRequest.indicesOptions());
if (ClusterInfoRequest.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 @@ -514,7 +543,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 @@ -539,7 +570,9 @@ static Request indicesExist(org.elasticsearch.action.admin.indices.get.GetIndexR
RequestConverters.Params params = new RequestConverters.Params();
params.withLocal(getIndexRequest.local());
params.withHuman(getIndexRequest.humanReadable());
params.withIndicesOptions(getIndexRequest.indicesOptions());
if (ClusterInfoRequest.DEFAULT_INDICES_OPTIONS.equals(getIndexRequest.indicesOptions()) == false) {
params.withIndicesOptions(getIndexRequest.indicesOptions());
}
params.withIncludeDefaults(getIndexRequest.includeDefaults());
params.putParam(INCLUDE_TYPE_NAME_PARAMETER, "true");
request.addParameters(params.asMap());
Expand All @@ -557,7 +590,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 @@ -570,7 +605,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 @@ -662,7 +699,9 @@ static Request validateQuery(ValidateQueryRequest validateQueryRequest) throws I
String endpoint = RequestConverters.endpoint(indices, types, "_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 @@ -677,7 +716,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 @@ -807,7 +848,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

0 comments on commit 704752b

Please sign in to comment.