Invalid response for _forcemerge, _cache/clear APIs when unassigned shards

Hi,

Issue
When _forcemerge is tried on an index or a group of indices that has some unassigned shards, the response returned does not indicate failures for unassigned shards. Even the total, failed and successful counts don't seem to tally.

This is true for index _cache/clear and index _stats API as well.

Failure Logs

It can be seen that, successful + failed != total here

➜  curl localhost:9200/_cat/shards
my_index 0 p UNASSIGNED
my_index 0 r UNASSIGNED

➜  curl -XPOST "localhost:9200/my_index/_forcemerge?pretty"  -d'{}' -H 'Content-Type: application/json'
{
  "_shards" : {
    "total" : 2,
    "successful" : 0,
    "failed" : 0
  }
}

Probable Cause
In the TransportBroadcastByNodeAction, if a shard that requires action is unassigned, it is added to the unavailableShardExceptions list but at the time of collating responses, this list is not added to the failedShards and other exceptions for reporting in response

Is this a bug?

Thanks!

Hi Guys,

Could someone look into this please?

Regards