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

Snapshot status api: make sure headers are handed over to inner nodes request #9409

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,20 +22,18 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.nodes.*;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.ClusterService;
import org.elasticsearch.cluster.metadata.SnapshotId;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus;
import org.elasticsearch.snapshots.SnapshotsService;
Expand All @@ -61,10 +59,6 @@ public TransportNodesSnapshotsStatus(Settings settings, ClusterName clusterName,
this.snapshotsService = snapshotsService;
}

public void status(String[] nodesIds, SnapshotId[] snapshotIds, @Nullable TimeValue timeout, ActionListener<NodesSnapshotStatus> listener) {
execute(new Request(nodesIds).snapshotIds(snapshotIds).timeout(timeout), listener);
}

@Override
protected String executor() {
return ThreadPool.Names.GENERIC;
Expand Down Expand Up @@ -155,8 +149,8 @@ static class Request extends NodesOperationRequest<Request> {
public Request() {
}

public Request(String[] nodesIds) {
super(nodesIds);
public Request(ActionRequest request, String[] nodesIds) {
super(request, nodesIds);
}

public Request snapshotIds(SnapshotId[] snapshotIds) {
Expand Down
Expand Up @@ -21,7 +21,6 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ElasticsearchIllegalArgumentException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
Expand Down Expand Up @@ -111,8 +110,9 @@ protected void masterOperation(final SnapshotsStatusRequest request,
snapshotIds[i] = currentSnapshots.get(i).snapshotId();
}

transportNodesSnapshotsStatus.status(nodesIds.toArray(new String[nodesIds.size()]),
snapshotIds, request.masterNodeTimeout(), new ActionListener<TransportNodesSnapshotsStatus.NodesSnapshotStatus>() {
TransportNodesSnapshotsStatus.Request nodesRequest = new TransportNodesSnapshotsStatus.Request(request, nodesIds.toArray(new String[nodesIds.size()]))
.snapshotIds(snapshotIds).timeout(request.masterNodeTimeout());
transportNodesSnapshotsStatus.execute(nodesRequest, new ActionListener<TransportNodesSnapshotsStatus.NodesSnapshotStatus>() {
@Override
public void onResponse(TransportNodesSnapshotsStatus.NodesSnapshotStatus nodeSnapshotStatuses) {
try {
Expand Down
Expand Up @@ -43,6 +43,11 @@ protected NodesOperationRequest() {

}

protected NodesOperationRequest(ActionRequest request, String... nodesIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean that all node operation requests suffer from the same issue? did you check for other potential bugs around this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of the other requests that extend this one are user facing requests, this is the only case where we extended for an internal request that actually needed the headers copied from the parent request. We are good ;)

super(request);
this.nodesIds = nodesIds;
}

protected NodesOperationRequest(String... nodesIds) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this constructor should be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could remove it, but it's used by other requests that are created directly through java api, for instance nodes hot threads, nodes info etc. those don't need headers in their constructor, as the client automatically copies over the headers in the Rest action.

this.nodesIds = nodesIds;
}
Expand Down