Skip to content

Commit 66c6909

Browse files
committed
Collect shard sizes for closed indices (#50645)
Today the `InternalClusterInfoService` collects information on the sizes of shards of open indices, but does not consider closed indices. This means that shards of closed indices are treated as having zero size when they are being allocated. This commit fixes this, obtaining the sizes of all shards. Relates #33888
1 parent 312bf44 commit 66c6909

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest;
3131
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
3232
import org.elasticsearch.action.admin.indices.stats.ShardStats;
33+
import org.elasticsearch.action.support.IndicesOptions;
3334
import org.elasticsearch.client.node.NodeClient;
3435
import org.elasticsearch.cluster.block.ClusterBlockException;
3536
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -258,6 +259,7 @@ protected CountDownLatch updateIndicesStats(final ActionListener<IndicesStatsRes
258259
final IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest();
259260
indicesStatsRequest.clear();
260261
indicesStatsRequest.store(true);
262+
indicesStatsRequest.indicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_CLOSED);
261263

262264
client.admin().indices().stats(indicesStatsRequest, new LatchedActionListener<>(listener, latch));
263265
return latch;

server/src/test/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@ private void setClusterInfoTimeout(String timeValue) {
114114
.put(InternalClusterInfoService.INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.getKey(), timeValue).build()));
115115
}
116116

117-
public void testClusterInfoServiceCollectsInformation() throws Exception {
117+
public void testClusterInfoServiceCollectsInformation() {
118118
internalCluster().startNodes(2);
119119
assertAcked(prepareCreate("test").setSettings(Settings.builder()
120120
.put(Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), 0)
121121
.put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE).build()));
122+
if (randomBoolean()) {
123+
assertAcked(client().admin().indices().prepareClose("test"));
124+
}
122125
ensureGreen("test");
123126
InternalTestCluster internalTestCluster = internalCluster();
124127
// Get the cluster info service on the master node

0 commit comments

Comments
 (0)