-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Prune Unhealthy Agents #6571
Prune Unhealthy Agents #6571
Conversation
command/forceleave/forceleave.go
Outdated
if err != nil { | ||
c.UI.Error(fmt.Sprintf("Error force leaving: %s", err)) | ||
return 1 | ||
switch c.prune { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems more natural to use if c.prune { ... } else { ... }
instead of a boolean switch statement here.
Also you can move the common error handling outside of the conditional block, like:
if c.prune {
err = client.Agent().ForceLeavePrune(...)
} else {
err = client.Agent().ForceLeave(...)
}
if err != nil {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say natural, do you mean easier to read? Or what do you mean by natural?
Not against your suggestion, but I'm wondering which is more idiomatic but also user friendly? I've been going back and forth on which is better, why, and when to use a switch versus an if/else. Feedback would be amazing ❤️
(Perhaps it's more like the rest of Consul code to be an if/else 🤷♀ ?)
Since you are changing the HTTP API for /v1/agent/force-leave you should also update the API docs in the website as well. |
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
…s, general cleanup
Necessary Serf stuff has been added and re-vendored. 🤞 Updated those API docs, as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few little things and possibly two control flow bugs.
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
Co-Authored-By: R.B. Boyer <rb@hashicorp.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Add -prune flag to ForceLeave
Note: #580 in Serf needs to be merged, Serf to be tagged, Consul re-vendored and the go.mod updated.
This allows for users to remove unhealthy agents by adding the
-prune
flag in the CLI. This will completely remove the agent from the list of members.If you are pruning a server from WAN you should specify your command like such
consul force-leave -prune nodename.datacenter
, as the formatting that we have added doesn't always work.Fixes #2981