mirror of https://github.com/status-im/consul.git
api: enable query options on agent force-leave endpoint (#15987)
This commit is contained in:
parent
5d7a7ff041
commit
eb9f671eaf
|
@ -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
|
||||
// completely from the list of members.
|
||||
//
|
||||
// DEPRECATED - Use ForceLeaveOptions instead.
|
||||
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.setQueryOptions(q)
|
||||
if opts.Prune {
|
||||
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) {
|
||||
t.Parallel()
|
||||
c, s := makeClient(t)
|
||||
|
|
Loading…
Reference in New Issue