Skip to content

Commit

Permalink
Changing name of shards field in node/stats api to shard_stats (elast…
Browse files Browse the repository at this point in the history
…ic#78531)

If the _nodes/stats API received a level=shards request parameter, then the response would have two "shards" fields,
which would cause problems with json parsers. This commit renames the "shards" field that currently only contains
"total_count" to "shard_stats".
Relates elastic#78311 elastic#75433
  • Loading branch information
masseyke committed Oct 6, 2021
1 parent d4fee27 commit 3ce1e16
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions docs/reference/cluster/nodes-stats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -960,11 +960,11 @@ Time in milliseconds
recovery operations were delayed due to throttling.
=======
`shards`::
`shards_stats`::
(object)
Contains statistics about all shards assigned to the node.
+
.Properties of `shards`
.Properties of `shard_stats`
[%collapsible%open]
=======
`total_count`::
Expand Down
2 changes: 2 additions & 0 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


apply plugin: 'elasticsearch.build'
apply plugin: 'elasticsearch.publish'
apply plugin: 'elasticsearch.rest-resources'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"store",
"warmer",
"suggest",
"shards"
"shard_stats"
],
"description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified."
}
Expand Down Expand Up @@ -177,7 +177,7 @@
"store",
"warmer",
"suggest",
"shards"
"shard_stats"
],
"description":"Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
- is_false: nodes.$node_id.indices.segments
- is_false: nodes.$node_id.indices.translog
- is_false: nodes.$node_id.indices.recovery
- is_false: nodes.$node_id.indices.shards
- is_false: nodes.$node_id.indices.shard_stats

---
"Metric - multi":
Expand Down Expand Up @@ -167,7 +167,7 @@
- is_false: nodes.$node_id.indices.segments
- is_false: nodes.$node_id.indices.translog
- is_true: nodes.$node_id.indices.recovery
- is_false: nodes.$node_id.indices.shards
- is_false: nodes.$node_id.indices.shard_stats

---
"Metric - _all include_segment_file_sizes":
Expand Down Expand Up @@ -225,7 +225,7 @@
- is_true: nodes.$node_id.indices.segments
- is_false: nodes.$node_id.indices.translog
- is_false: nodes.$node_id.indices.recovery
- is_false: nodes.$node_id.indices.shards
- is_false: nodes.$node_id.indices.shard_stats
- is_true: nodes.$node_id.indices.segments.file_sizes

---
Expand Down Expand Up @@ -257,7 +257,7 @@
- is_true: nodes.$node_id.indices.segments
- is_false: nodes.$node_id.indices.translog
- is_false: nodes.$node_id.indices.recovery
- is_false: nodes.$node_id.indices.shards
- is_false: nodes.$node_id.indices.shard_stats

---
"Metric - _all include_unloaded_segments":
Expand Down Expand Up @@ -321,10 +321,10 @@
# null and cannot be tested here

---
"Metric - blank for indices shards":
"Metric - blank for indices shard_stats":
- skip:
features: [arbitrary_key]
version: " - 7.14.99"
version: " - 7.16.1"
reason: "total shard count added in version 7.15.0"
- do:
nodes.info: {}
Expand All @@ -334,14 +334,14 @@
- do:
nodes.stats: {}

- is_true: nodes.$node_id.indices.shards
- match: { nodes.$node_id.indices.shards.total_count: 0 }
- is_true: nodes.$node_id.indices.shard_stats
- match: { nodes.$node_id.indices.shard_stats.total_count: 0 }

---
"Metric - _all for indices shards":
"Metric - _all for indices shard_stats":
- skip:
features: [arbitrary_key]
version: " - 7.14.99"
version: " - 7.16.1"
reason: "total shard count added in version 7.15.0"
- do:
nodes.info: {}
Expand All @@ -351,16 +351,16 @@
- do:
nodes.stats: { metric: _all }

- is_true: nodes.$node_id.indices.shards
- match: { nodes.$node_id.indices.shards.total_count: 0 }
- is_true: nodes.$node_id.indices.shard_stats
- match: { nodes.$node_id.indices.shard_stats.total_count: 0 }


---
"indices shards total count test":
"indices shard_stats total count test":

- skip:
features: ["allowed_warnings", arbitrary_key]
version: " - 7.14.99"
version: " - 7.16.1"
reason: "total shard count added in version 7.15.0"

- do:
Expand All @@ -387,4 +387,4 @@
- do:
nodes.stats: { metric: _all }

- gte: { nodes.$node_id.indices.shards.total_count: 1 }
- gte: { nodes.$node_id.indices.shard_stats.total_count: 1 }
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public enum Flag {
// 14 was previously used for Suggest
RequestCache("request_cache", 15),
Recovery("recovery", 16),
Shards("shards", 18);
Shards("shard_stats", 18);

private final String restName;
private final int index;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void writeTo(StreamOutput out) throws IOException {
}

static final class Fields {
static final String SHARDS = "shards";
static final String SHARDS = "shard_stats";
static final String TOTAL_COUNT = "total_count";
}

Expand Down

0 comments on commit 3ce1e16

Please sign in to comment.