Skip to content

Commit

Permalink
Add support for x_opaque_id to _cat/tasks (#63036) (#63135)
Browse files Browse the repository at this point in the history
Adds an optional column with support for x_opaque_id to _cat/tasks API.

Closes #61118
  • Loading branch information
imotov authored Oct 1, 2020
1 parent 7f6d198 commit 6a9cde2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@
$body: |
/ # action task_id parent_task_id type start_time timestamp running_time ip node description
^( \S+\s+ \S+\:\d+\s+ (?:\-|\S+\:\d+)\s+ \S+\s+ \d+\s+ \d\d\:\d\d\:\d\d\s+ \S+\s+ \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s+ \S+\s+ .*\n)+$/
---
"Test cat tasks output with X-Opaque-Id":
- skip:
version: " - 7.9.99"
reason: support for opaque_id was added in 7.10.0
features: headers

- do:
headers: { "X-Opaque-Id": "TestID" }
cat.tasks:
h: ["action", "x_opaque_id"]

- match:
$body: /TestID/
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.action.RestResponseListener;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskInfo;

import java.time.Instant;
Expand Down Expand Up @@ -117,6 +118,7 @@ protected Table getTableWithHeader(final RestRequest request) {
table.addCell("port", "default:false;alias:po;desc:bound transport port");
table.addCell("node", "default:true;alias:n;desc:node name");
table.addCell("version", "default:false;alias:v;desc:es version");
table.addCell("x_opaque_id", "default:false;alias:x;desc:X-Opaque-ID header");

// Task detailed info
if (detailed) {
Expand Down Expand Up @@ -153,6 +155,7 @@ private void buildRow(Table table, boolean fullId, boolean detailed, DiscoveryNo
table.addCell(node.getAddress().address().getPort());
table.addCell(node == null ? "-" : node.getName());
table.addCell(node == null ? "-" : node.getVersion().toString());
table.addCell(taskInfo.getHeaders().getOrDefault(Task.X_OPAQUE_ID, "-"));

if (detailed) {
table.addCell(taskInfo.getDescription());
Expand Down

0 comments on commit 6a9cde2

Please sign in to comment.