Ensure that Proxies ARE always cleaned up, event with DeregisterCriticalServiceAfter (#4649)

This fixes https://github.com/hashicorp/consul/issues/4648
This commit is contained in:
Pierre Souchay 2018-09-11 18:34:09 +02:00 committed by Paul Banks
parent b66763eb33
commit 2fe728c7bd
2 changed files with 9 additions and 9 deletions

View File

@ -1818,6 +1818,15 @@ func (a *Agent) RemoveService(serviceID string, persist bool) error {
}
}
// Remove the associated managed proxy if it exists
for proxyID, p := range a.State.Proxies() {
if p.Proxy.TargetServiceID == serviceID {
if err := a.RemoveProxy(proxyID, true); err != nil {
return err
}
}
}
a.logger.Printf("[DEBUG] agent: removed service %q", serviceID)
return nil
}

View File

@ -682,15 +682,6 @@ func (s *HTTPServer) AgentDeregisterService(resp http.ResponseWriter, req *http.
return nil, err
}
// Remove the associated managed proxy if it exists
for proxyID, p := range s.agent.State.Proxies() {
if p.Proxy.TargetServiceID == serviceID {
if err := s.agent.RemoveProxy(proxyID, true); err != nil {
return nil, err
}
}
}
s.syncChanges()
return nil, nil
}