Skip to content

Commit

Permalink
query for leader in operator debug command
Browse files Browse the repository at this point in the history
The `operator debug` command doesn't output the leader anywhere in the
output, which adds extra burden to offline debugging (away from an
ongoing incident where you can simply check manually). Query the
`/v1/status/leader` API but degrade gracefully.
  • Loading branch information
tgross committed Jun 27, 2022
1 parent f5b8506 commit c801205
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions command/operator_debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,18 @@ func (c *OperatorDebugCommand) Run(args []string) int {
// Write complete list of server members to file
c.writeJSON(clusterDir, "members.json", c.members, err)

// Get leader and write to file; there's no option for AllowStale
// on this API and a stale result wouldn't even be meaningful, so
// only warn if we fail so that we don't stop the rest of the
// debugging
leader, err := client.Status().Leader()
if err != nil {
c.Ui.Warn(fmt.Sprintf("Failed to retrieve leader; err: %v", err))
}
if len(leader) > 0 {
c.writeJSON(clusterDir, "leader.json", leader, err)
}

// Filter for servers matching criteria
c.serverIDs, err = filterServerMembers(c.members, serverIDs, c.region)
if err != nil {
Expand Down

0 comments on commit c801205

Please sign in to comment.