Skip to content

Commit

Permalink
[CCR] Follow stats api should return a 404 when requesting stats for
Browse files Browse the repository at this point in the history
non existing indices.

Currently it returns an empty response with a 200 response code.

Closes elastic#37021
  • Loading branch information
martijnvg committed Jan 8, 2019
1 parent c980cc1 commit b9331d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit b9331d3

Please sign in to comment.