Skip to content

Commit

Permalink
Handle missed error case in seal status output format
Browse files Browse the repository at this point in the history
Fixes #3998
  • Loading branch information
jefferai committed Feb 18, 2018
1 parent 8ded4d2 commit 1aee220
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions command/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,35 @@ func OutputSealStatus(ui cli.Ui, client *api.Client, status *api.SealStatusRespo
leaderStatus, err := client.Sys().Leader()
if err != nil && strings.Contains(err.Error(), "Vault is sealed") {
leaderStatus = &api.LeaderResponse{HAEnabled: true}
err = nil
}
if err != nil {
ui.Error(fmt.Sprintf("Error checking leader status: %s", err))
return 1
}

// Output if HA is enabled
out = append(out, fmt.Sprintf("HA Enabled | %t", leaderStatus.HAEnabled))
if leaderStatus.HAEnabled {
mode := "sealed"
if !status.Sealed {
out = append(out, fmt.Sprintf("HA Cluster | %s", leaderStatus.LeaderClusterAddress))
mode = "standby"
showLeaderAddr := false
if leaderStatus.IsSelf {
mode = "active"
} else {
if leaderStatus.LeaderAddress == "" {
leaderStatus.LeaderAddress = "<none>"
}
showLeaderAddr = true
}
}
out = append(out, fmt.Sprintf("HA Mode | %s", mode))

out = append(out, fmt.Sprintf("HA Mode | %s", mode))

if !status.Sealed {
out = append(out, fmt.Sprintf("HA Cluster | %s", leaderStatus.LeaderClusterAddress))
// This is down here just to keep ordering consistent
if showLeaderAddr {
out = append(out, fmt.Sprintf("Active Node Address: | %s", leaderStatus.LeaderAddress))
}
}
}

Expand Down

0 comments on commit 1aee220

Please sign in to comment.