Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display messages from serf in cli #5236

Merged
merged 2 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/operator_keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type KeyringResponse struct {
// Segment has the network segment this request corresponds to.
Segment string

// Messages has information or errors from serf
Messages map[string]string `json:",omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter that these messages will be randomly ordered? If you stored them as something like [][]string instead of map[string]string then at least you could retain the ordering.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messages are already in the response from

type KeyringResponse struct {
WAN bool
Datacenter string
Segment string
Messages map[string]string `json:",omitempty"`
Keys map[string]int
NumNodes int
Error string `json:",omitempty"`
}

I only added it here so that it gets deserialized.

Since the results are collected in parallel from all the nodes, I wouldn't even be sure how to order them. The order of arrival could be different every time as well.


// A map of the encryption keys to the number of nodes they're installed on
Keys map[string]int

Expand Down
5 changes: 5 additions & 0 deletions command/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ func (c *cmd) handleList(responses []*consulapi.KeyringResponse) {

c.UI.Output("")
c.UI.Output(pool + ":")

for from, msg := range response.Messages {
c.UI.Output(fmt.Sprintf(" ===> %s: %s", from, msg))
}

for key, num := range response.Keys {
c.UI.Output(fmt.Sprintf(" %s [%d/%d]", key, num, response.NumNodes))
}
Expand Down