Skip to content

Commit

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

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 #78311 #75433 #78531
  • Loading branch information
masseyke authored Oct 7, 2021
1 parent d4fee27 commit 2317fdf
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 24 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,11 +321,11 @@
# 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"
reason: "total shard count added in version 7.15.0"
version: " - 7.15.0"
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"
- do:
nodes.info: {}
- set:
Expand All @@ -334,15 +334,15 @@
- 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"
reason: "total shard count added in version 7.15.0"
version: " - 7.15.0"
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"
- do:
nodes.info: {}
- set:
Expand All @@ -351,17 +351,17 @@
- 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"
reason: "total shard count added in version 7.15.0"
version: " - 7.15.0"
reason: "total shard count added in version 7.15.0, and fixed in 7.15.1"

- do:
indices.create:
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 2317fdf

Please sign in to comment.