Skip to content

Commit

Permalink
Add ?master_node_timeout to RestDeprecationInfoAction (#108714)
Browse files Browse the repository at this point in the history
Relates #107984
  • Loading branch information
DaveCTurner committed May 16, 2024
1 parent ca94162 commit e454165
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.transport.Transports;
Expand Down Expand Up @@ -330,8 +331,8 @@ public static class Request extends MasterNodeReadRequest<Request> implements In
private static final IndicesOptions INDICES_OPTIONS = IndicesOptions.fromOptions(false, true, true, true);
private String[] indices;

public Request(String... indices) {
super(TRAPPY_IMPLICIT_DEFAULT_MASTER_NODE_TIMEOUT);
public Request(TimeValue masterNodeTimeout, String... indices) {
super(masterNodeTimeout);
this.indices = indices;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.elasticsearch.core.RestApiVersion;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestUtils;
import org.elasticsearch.rest.action.RestToXContentListener;
import org.elasticsearch.xpack.deprecation.DeprecationInfoAction.Request;

Expand Down Expand Up @@ -46,7 +47,10 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client
}

private static RestChannelConsumer handleGet(final RestRequest request, NodeClient client) {
Request infoRequest = new Request(Strings.splitStringByCommaToArray(request.param("index")));
final var infoRequest = new Request(
RestUtils.getMasterNodeTimeout(request),
Strings.splitStringByCommaToArray(request.param("index"))
);
return channel -> client.execute(DeprecationInfoAction.INSTANCE, infoRequest, new RestToXContentListener<>(channel));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class DeprecationInfoActionRequestTests extends AbstractWireSerializingTe

@Override
protected DeprecationInfoAction.Request createTestInstance() {
return new DeprecationInfoAction.Request(randomAlphaOfLength(10));
return new DeprecationInfoAction.Request(randomTimeValue(), randomAlphaOfLength(10));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void testFrom() throws IOException {
emptyList()
);

DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(Strings.EMPTY_ARRAY);
DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(randomTimeValue(), Strings.EMPTY_ARRAY);
DeprecationInfoAction.Response response = DeprecationInfoAction.Response.from(
state,
resolver,
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testFromWithMergeableNodeIssues() throws IOException {
emptyList()
);

DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(Strings.EMPTY_ARRAY);
DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(randomTimeValue(), Strings.EMPTY_ARRAY);
DeprecationInfoAction.Response response = DeprecationInfoAction.Response.from(
state,
resolver,
Expand Down Expand Up @@ -263,7 +263,7 @@ public void testRemoveSkippedSettings() throws IOException {
emptyList()
);

DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(Strings.EMPTY_ARRAY);
DeprecationInfoAction.Request request = new DeprecationInfoAction.Request(randomTimeValue(), Strings.EMPTY_ARRAY);
DeprecationInfoAction.Response.from(
state,
resolver,
Expand Down

0 comments on commit e454165

Please sign in to comment.