Elasticsearch: Treat "unable to find any unassigned shards to explain" as a successful response?

Created on 28 Jun 2017  路  4Comments  路  Source: elastic/elasticsearch

5.3.1, 5.4.2

When the cluster allocation explain api is called against a cluster that has no unassigned shards, it currently throws an error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "remote_transport_exception",
        "reason" : "[][][cluster:monitor/allocation/explain]"
      }
    ],
    "type" : "illegal_state_exception",
    "reason" : "unable to find any unassigned shards to explain [ClusterAllocationExplainRequest[useAnyUnassignedShard=true,includeYesDecisions?=true]"
  },
  "status" : 500
}

And writes a WARN entry to the log file:

[2017-06-28T00:14:20,342][WARN ][r.suppressed             ] path: /_cluster/allocation/explain, params: {pretty=, include_yes_decisions=}
org.elasticsearch.transport.RemoteTransportException: [][][cluster:monitor/allocation/explain]
Caused by: java.lang.IllegalStateException: unable to find any unassigned shards to explain [ClusterAllocationExplainRequest[useAnyUnassignedShard=true,includeYesDecisions?=true]
    at org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction.findShardToExplain(TransportClusterAllocationExplainAction.java:142) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction.masterOperation(TransportClusterAllocationExplainAction.java:99) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.action.admin.cluster.allocation.TransportClusterAllocationExplainAction.masterOperation(TransportClusterAllocationExplainAction.java:54) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.action.support.master.TransportMasterNodeAction.masterOperation(TransportMasterNodeAction.java:87) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction$2.doRun(TransportMasterNodeAction.java:166) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:638) ~[elasticsearch-5.3.1.jar:5.3.1]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.3.1.jar:5.3.1]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_111]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]

It will be nice for the API to treat "unable to find any unassigned shards to explain" as a successful response (and indicate in the response body that unassigned shards found is 0, for example), and simply write an informational statement to the debug log instead of having it show up as a warning in the ES logs.

:CorInfrLogging >enhancement help wanted

Most helpful comment

I disagree. This is the kind of leniency that we try to avoid these days. The explain API is for understanding why an unassigned shard can not be assigned, returning a non-successful response says: the state of the system does not match the intended use of this API. I think it shouldn't be a 500 (server error) but a 400 (user error) though.

All 4 comments

I disagree. This is the kind of leniency that we try to avoid these days. The explain API is for understanding why an unassigned shard can not be assigned, returning a non-successful response says: the state of the system does not match the intended use of this API. I think it shouldn't be a 500 (server error) but a 400 (user error) though.

We discussed this during Fix-it-Friday. There was broad agreement with my previous comment and we should only make the change that this results in a 400 and not a 500.

Thanks, treating it as a bad request vs. a server error sounds good to me, thx for the PR 馃憤

You're welcome but the thanks are due to you for raising the issue in the first place so we can iterate an improvement.

Was this page helpful?
0 / 5 - 0 ratings