mirror of https://github.com/status-im/consul.git
agent: RemoveProxy also removes the proxy service
This commit is contained in:
parent
e2653bec02
commit
a82726f0b8
|
@ -2185,7 +2185,14 @@ func (a *Agent) RemoveProxy(proxyID string, persist bool) error {
|
|||
}
|
||||
|
||||
// Remove the proxy from the local state
|
||||
if _, err := a.State.RemoveProxy(proxyID); err != nil {
|
||||
p, err := a.State.RemoveProxy(proxyID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove the proxy service as well. The proxy ID is also the ID
|
||||
// of the servie, but we might as well use the service pointer.
|
||||
if err := a.RemoveService(p.Proxy.ProxyService.ID, persist); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -2706,14 +2706,14 @@ func TestAgent_RemoveProxy(t *testing.T) {
|
|||
|
||||
// Test the ID was created as we expect.
|
||||
gotProxy := a.State.Proxy("web-proxy")
|
||||
gotProxy.Proxy.ProxyService = nil
|
||||
require.Equal(pReg, gotProxy.Proxy)
|
||||
require.NotNil(gotProxy)
|
||||
|
||||
err := a.RemoveProxy("web-proxy", false)
|
||||
require.NoError(err)
|
||||
|
||||
gotProxy = a.State.Proxy("web-proxy")
|
||||
require.Nil(gotProxy)
|
||||
require.Nil(a.State.Service("web-proxy"), "web-proxy service")
|
||||
|
||||
// Removing invalid proxy should be an error
|
||||
err = a.RemoveProxy("foobar", false)
|
||||
|
|
Loading…
Reference in New Issue