Skip to content

Commit

Permalink
Expose roles by default in cat allocation API (elastic#101753)
Browse files Browse the repository at this point in the history
In elastic#96994 we added a column for node roles to the `GET _cat/allocation`
API but left it hidden by default to avoid changing behaviour. In fact
it's ok to change the behaviour of the CAT APIs since they're only
intended for human consumption, and it's awfully useful to see the node
roles in this API response, so this commit makes this column display by
default.
  • Loading branch information
DaveCTurner authored Nov 7, 2023
1 parent e3b8611 commit 4b1909a
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/101753.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 101753
summary: Expose roles by default in cat allocation API
area: CAT APIs
type: enhancement
issues: []
8 changes: 4 additions & 4 deletions docs/reference/cat/allocation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[IMPORTANT]
====
cat APIs are only intended for human consumption using the command line or {kib}
cat APIs are only intended for human consumption using the command line or {kib}
console. They are _not_ intended for use by applications.
====

Expand Down Expand Up @@ -113,10 +113,10 @@ The API returns the following response:

[source,txt]
--------------------------------------------------
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node
1 260b 47.3gb 43.4gb 100.7gb 46 127.0.0.1 127.0.0.1 CSUXak2
shards disk.indices disk.used disk.avail disk.total disk.percent host ip node node.role
1 260b 47.3gb 43.4gb 100.7gb 46 127.0.0.1 127.0.0.1 CSUXak2 himrst
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/ s/46/\\d+/]
// TESTRESPONSE[s/CSUXak2/.+/ non_json]
// TESTRESPONSE[s/CSUXak2 himrst/.+/ non_json]

This response shows a single shard is allocated to the one node available.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
---
"One index":

- skip:
version: " - 8.11.99"
reason: "node.role column shown by default from 8.12.0 onwards"

- do:
indices.create:
index: test
Expand All @@ -45,20 +49,25 @@
(\d+ \s+) #always should return value since we filter out non data nodes by default
[-\w.]+ \s+
\d+(\.\d+){3} \s+
[-\w.]+
[-\w.]+ \s+
[\w]+
\n
)+
(
\s* #allow leading spaces to account for right-justified text
\d+ \s+
UNASSIGNED
UNASSIGNED \s*
\n
)?
$/
---
"Node ID":

- skip:
version: " - 8.11.99"
reason: "node.role column shown by default from 8.12.0 onwards"

- do:
cat.allocation:
node_id: _master
Expand All @@ -74,7 +83,8 @@
(\d+ \s+)? #no value from client nodes
[-\w.]+ \s+
\d+(\.\d+){3} \s+
[-\w.]+
[-\w.]+ \s+
[\w]+
\n
)
$/
Expand All @@ -92,6 +102,10 @@

"All Nodes":

- skip:
version: " - 8.11.99"
reason: "node.role column shown by default from 8.12.0 onwards"

- do:
cat.allocation:
node_id: "*"
Expand All @@ -108,20 +122,25 @@
(\d+ \s+)? #no value from client nodes
[-\w.]+ \s+
\d+(\.\d+){3} \s+
[-\w.]+
[-\w.]+ \s+
[\w]+
\n
)+
(
\s* #allow leading spaces to account for right-justified text
\d+ \s+
UNASSIGNED
UNASSIGNED \s*
\n
)?
$/
---
"Column headers":

- skip:
version: " - 8.11.99"
reason: "node.role column shown by default from 8.12.0 onwards"

- do:
cat.allocation:
v: true
Expand All @@ -136,7 +155,8 @@
disk.percent \s+
host \s+
ip \s+
node
node \s+
node.role
\n
( \s* #allow leading spaces to account for right-justified text
Expand All @@ -148,7 +168,8 @@
(\d+ \s+) #always should return value since we filter out non data nodes by default
[-\w.]+ \s+
\d+(\.\d+){3} \s+
[-\w.]+
[-\w.]+ \s+
[\w]+
\n
)+
$/
Expand Down Expand Up @@ -193,6 +214,10 @@

"Bytes":

- skip:
version: " - 8.11.99"
reason: "node.role column shown by default from 8.12.0 onwards"

- do:
cat.allocation:
bytes: gb
Expand All @@ -208,7 +233,8 @@
(\d+ \s+) #always should return value since we filter out non data nodes by default
[-\w.]+ \s+
\d+(\.\d+){3} \s+
[-\w.]+
[-\w.]+ \s+
[\w]+
\n
)+
$/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected Table getTableWithHeader(final RestRequest request) {
table.addCell("host", "alias:h;desc:host of node");
table.addCell("ip", "desc:ip of node");
table.addCell("node", "alias:n;desc:name of node");
table.addCell("node.role", "default:false;alias:r,role,nodeRole;desc:node roles");
table.addCell("node.role", "alias:r,role,nodeRole;desc:node roles");
table.endHeaders();
return table;
}
Expand Down

0 comments on commit 4b1909a

Please sign in to comment.