From 07aeaa337f981ebee3cc17919550168b90bc44b6 Mon Sep 17 00:00:00 2001 From: davemay99 Date: Wed, 27 Oct 2021 11:40:47 -0400 Subject: [PATCH 1/4] debug: default node-id to all --- command/operator_debug.go | 13 +++++++++---- website/content/docs/commands/operator/debug.mdx | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/command/operator_debug.go b/command/operator_debug.go index 183722f35a5..3a621434f7d 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -147,7 +147,7 @@ Debug Options: Cap the maximum number of client nodes included in the capture. Defaults to 10, set to 0 for unlimited. - -node-id=, + -node-id=, Comma separated list of Nomad client node ids to monitor for logs, API outputs, and pprof profiles. Accepts id prefixes, and "all" to select all nodes (up to count = max-nodes). Defaults to "all". @@ -287,7 +287,7 @@ func (c *OperatorDebugCommand) Run(args []string) int { flags.StringVar(&c.logLevel, "log-level", "DEBUG", "") flags.IntVar(&c.maxNodes, "max-nodes", 10, "") flags.StringVar(&c.nodeClass, "node-class", "", "") - flags.StringVar(&nodeIDs, "node-id", "", "") + flags.StringVar(&nodeIDs, "node-id", "all", "") flags.StringVar(&serverIDs, "server-id", "all", "") flags.BoolVar(&c.stale, "stale", false, "") flags.StringVar(&output, "output", "", "") @@ -450,8 +450,13 @@ func (c *OperatorDebugCommand) Run(args []string) int { // Return error if nodes were specified but none were found if len(nodeIDs) > 0 && nodeCaptureCount == 0 { - c.Ui.Error(fmt.Sprintf("Failed to retrieve clients, 0 nodes found in list: %s", nodeIDs)) - return 1 + if nodeIDs == "all" { + // It's okay to have zero clients for default "all" + c.Ui.Info("Note: \"-node-id=all\" specified but no clients found") + } else { + c.Ui.Error(fmt.Sprintf("Failed to retrieve clients, 0 nodes found in list: %s", nodeIDs)) + return 1 + } } // Resolve servers diff --git a/website/content/docs/commands/operator/debug.mdx b/website/content/docs/commands/operator/debug.mdx index bfb4bf29566..bf392bd0116 100644 --- a/website/content/docs/commands/operator/debug.mdx +++ b/website/content/docs/commands/operator/debug.mdx @@ -61,9 +61,9 @@ true. - `-node-class=`: Filter client nodes based on node class. -- `-node-id=,`: Comma separated list of Nomad client node ids, - to monitor for logs and include pprof profiles. Accepts id prefixes, and - "all" to select all nodes (up to count = max-nodes). +- `-node-id=,`: Comma separated list of Nomad client node ids + to monitor for logs, API outputs, and pprof profiles. Accepts id prefixes, and + "all" to select all nodes (up to count = max-nodes). Defaults to `all`. - `-pprof-duration=`: Duration for pprof collection. Defaults to 1s. From c0f70bff75c8df1318ae9405e3d4dff77ff06f2e Mon Sep 17 00:00:00 2001 From: davemay99 Date: Wed, 27 Oct 2021 11:45:33 -0400 Subject: [PATCH 2/4] debug: align cli help and website documentation --- command/operator_debug.go | 9 +++++---- website/content/docs/commands/operator/debug.mdx | 16 ++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/command/operator_debug.go b/command/operator_debug.go index 3a621434f7d..c08a0b4ac2b 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -134,7 +134,8 @@ Vault Options: Debug Options: -duration= - The duration of the log monitor command. Defaults to 2m. + Set the duration of the debug capture. Logs will be captured from specified servers and + nodes at "log-level". Defaults to 2m. -interval= The interval between snapshots of the Nomad state. Set interval equal to @@ -158,7 +159,7 @@ Debug Options: -pprof-duration= Duration for pprof collection. Defaults to 1s. - -server-id=, + -server-id=, Comma separated list of Nomad server names to monitor for logs, API outputs, and pprof profiles. Accepts server names, "leader", or "all". Defaults to "all". @@ -169,8 +170,8 @@ Debug Options: necessary to get the configuration from a non-leader server. -output= - Path to the parent directory of the output directory. If not specified, an - archive is built in the current directory. + Path to the parent directory of the output directory. If specified no + archive is built. Defaults to the current directory. ` return strings.TrimSpace(helpText) } diff --git a/website/content/docs/commands/operator/debug.mdx b/website/content/docs/commands/operator/debug.mdx index bf392bd0116..579b4c77b2e 100644 --- a/website/content/docs/commands/operator/debug.mdx +++ b/website/content/docs/commands/operator/debug.mdx @@ -43,16 +43,15 @@ true. ## General Options -@include 'general_options_no_namespace.mdx' +@include 'general_options.mdx' ## Debug Options -- `-duration=2m`: Set the duration of the log monitor command. - Defaults to `"2m"`. Logs will be captured from specified servers and - nodes at `log-level`. +- `-duration=2m`: Set the duration of the debug capture. Logs will be captured from + specified servers and nodes at `log-level`. Defaults to `2m`. -- `-interval=2m`: The interval between snapshots of the Nomad state. - If unspecified, only one snapshot is captured. +- `-interval=30s`: The interval between snapshots of the Nomad state. + If unspecified, only one snapshot is captured. Defaults to `30s`. - `-log-level=DEBUG`: The log level to monitor. Defaults to `DEBUG`. @@ -67,8 +66,9 @@ true. - `-pprof-duration=`: Duration for pprof collection. Defaults to 1s. -- `-server-id=s1,s2`: Comma separated list of Nomad server names, "leader", or - "all" to monitor for logs and include pprof profiles. +- `-server-id=,`: Comma separated list of Nomad server names to + monitor for logs, API outputs, and pprof profiles. Accepts server names, "leader", or + "all". Defaults to `all`. - `-stale=`: If "false", the default, get membership data from the cluster leader. If the cluster is in an outage unable to establish From a90648e666cf5517255d36b9cb1e9452fa1a3192 Mon Sep 17 00:00:00 2001 From: davemay99 Date: Wed, 27 Oct 2021 13:34:37 -0400 Subject: [PATCH 3/4] grammatical adjustment --- command/operator_debug.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/operator_debug.go b/command/operator_debug.go index c08a0b4ac2b..6633f9c4f1c 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -170,7 +170,7 @@ Debug Options: necessary to get the configuration from a non-leader server. -output= - Path to the parent directory of the output directory. If specified no + Path to the parent directory of the output directory. If specified, no archive is built. Defaults to the current directory. ` return strings.TrimSpace(helpText) From 1bc87bc24264ee87e662df46202bce28cd824c0f Mon Sep 17 00:00:00 2001 From: davemay99 Date: Wed, 27 Oct 2021 13:42:30 -0400 Subject: [PATCH 4/4] Add changelog --- .changelog/11398.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/11398.txt diff --git a/.changelog/11398.txt b/.changelog/11398.txt new file mode 100644 index 00000000000..35b0845710b --- /dev/null +++ b/.changelog/11398.txt @@ -0,0 +1,3 @@ +```release-note:improvement +cli: Update `nomad operator debug` bundle to include sample of clients by default +```