api: enable query options on agent force-leave endpoint (#15987)
This commit is contained in:
parent
4f7d1b4700
commit
5c35095490
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:improvement
|
||||||
|
api: Enable setting query options on agent force-leave endpoint.
|
||||||
|
```
|
|
@ -1055,8 +1055,17 @@ func (a *Agent) ForceLeavePrune(node string) error {
|
||||||
|
|
||||||
// ForceLeaveOpts is used to have the agent eject a failed node or remove it
|
// ForceLeaveOpts is used to have the agent eject a failed node or remove it
|
||||||
// completely from the list of members.
|
// completely from the list of members.
|
||||||
|
//
|
||||||
|
// DEPRECATED - Use ForceLeaveOptions instead.
|
||||||
func (a *Agent) ForceLeaveOpts(node string, opts ForceLeaveOpts) error {
|
func (a *Agent) ForceLeaveOpts(node string, opts ForceLeaveOpts) error {
|
||||||
|
return a.ForceLeaveOptions(node, opts, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForceLeaveOptions is used to have the agent eject a failed node or remove it
|
||||||
|
// completely from the list of members. Allows usage of QueryOptions on-top of ForceLeaveOpts
|
||||||
|
func (a *Agent) ForceLeaveOptions(node string, opts ForceLeaveOpts, q *QueryOptions) error {
|
||||||
r := a.c.newRequest("PUT", "/v1/agent/force-leave/"+node)
|
r := a.c.newRequest("PUT", "/v1/agent/force-leave/"+node)
|
||||||
|
r.setQueryOptions(q)
|
||||||
if opts.Prune {
|
if opts.Prune {
|
||||||
r.params.Set("prune", "1")
|
r.params.Set("prune", "1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1365,6 +1365,20 @@ func TestAPI_AgentForceLeavePrune(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAPI_AgentForceLeaveOptions(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
c, s := makeClient(t)
|
||||||
|
defer s.Stop()
|
||||||
|
|
||||||
|
agent := c.Agent()
|
||||||
|
|
||||||
|
// Eject somebody with token
|
||||||
|
err := agent.ForceLeaveOptions(s.Config.NodeName, ForceLeaveOpts{Prune: true}, &QueryOptions{Token: "testToken"})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAPI_AgentMonitor(t *testing.T) {
|
func TestAPI_AgentMonitor(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
c, s := makeClient(t)
|
c, s := makeClient(t)
|
||||||
|
|
Loading…
Reference in New Issue