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:
parent
7a19f2a6da
commit
508b67c32a
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue