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
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
  • Loading branch information
masseyke authored Oct 6, 2021
1 parent 7e5e055 commit 4df15f5
Show file tree
Hide file tree
Showing 6 changed files with 24 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
3 changes: 3 additions & 0 deletions rest-api-spec/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTest("search.aggregation/20_terms/string profiler via global ordinals native implementation", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/string profiler via map", "The profiler results aren't backwards compatible.")
task.skipTest("search.aggregation/20_terms/numeric profiler", "The profiler results aren't backwards compatible.")
task.skipTest("nodes.stats/11_indices_metrics/Metric - _all for indices shards", "Muted because we are intentionally making a breaking bugfix. Unmute when #78531 is backported")
task.skipTest("nodes.stats/11_indices_metrics/indices shards total count test", "Muted because we are intentionally making a breaking bugfix. Unmute when #78531 is backported")
task.skipTest("nodes.stats/11_indices_metrics/Metric - blank for indices shards", "Muted because we are intentionally making a breaking bugfix. Unmute when #78531 is backported")

task.replaceValueInMatch("_type", "_doc")
task.addAllowedWarningRegex("\\[types removal\\].*")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"store",
"warmer",
"bulk",
"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",
"bulk",
"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 @@ -214,7 +214,7 @@ public enum Flag {
RequestCache("request_cache", 15),
Recovery("recovery", 16),
Bulk("bulk", 17),
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 4df15f5

Please sign in to comment.