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

Follow stats api should return a 404 when requesting stats for a non existing index #37220

Merged
merged 13 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -43,6 +43,12 @@
- is_true: follow_index_shards_acked
- is_true: index_following_started

- do:
ccr.follow_stats:
index: _all
- length: { indices: 1 }
- match: { indices.0.index: "bar" }

# we can not reliably wait for replication to occur so we test the endpoint without indexing any documents
- do:
ccr.follow_stats:
Expand Down Expand Up @@ -77,3 +83,7 @@
index: bar
- is_true: acknowledged

- do:
catch: missing
ccr.follow_stats:
index: unknown
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.TaskOperationFailure;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.tasks.TransportTasksAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.license.LicenseUtils;
Expand All @@ -37,13 +39,15 @@ public class TransportFollowStatsAction extends TransportTasksAction<
FollowStatsAction.StatsResponses, FollowStatsAction.StatsResponse> {

private final CcrLicenseChecker ccrLicenseChecker;
private final IndexNameExpressionResolver resolver;

@Inject
public TransportFollowStatsAction(
final ClusterService clusterService,
final TransportService transportService,
final ActionFilters actionFilters,
final CcrLicenseChecker ccrLicenseChecker) {
final CcrLicenseChecker ccrLicenseChecker,
final IndexNameExpressionResolver resolver) {
super(
FollowStatsAction.NAME,
clusterService,
Expand All @@ -54,6 +58,7 @@ public TransportFollowStatsAction(
FollowStatsAction.StatsResponse::new,
Ccr.CCR_THREAD_POOL_NAME);
this.ccrLicenseChecker = Objects.requireNonNull(ccrLicenseChecker);
this.resolver = resolver;
}

@Override
Expand All @@ -65,6 +70,10 @@ protected void doExecute(
listener.onFailure(LicenseUtils.newComplianceException("ccr"));
return;
}

String[] concreteIndices =
resolver.concreteIndexNames(clusterService.state(), IndicesOptions.strictExpandOpenAndForbidClosed(), request.indices());
request.setIndices(concreteIndices);
super.doExecute(task, request, listener);
}

Expand Down