Skip to content

Commit

Permalink
Ensure that Proxies ARE always cleaned up, event with DeregisterCriti…
Browse files Browse the repository at this point in the history
…calServiceAfter

This fixes hashicorp#4648
  • Loading branch information
pierresouchay committed Sep 11, 2018
1 parent f43540d commit 8d49058
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,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
}
Expand Down
9 changes: 0 additions & 9 deletions agent/agent_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,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
}
Expand Down

0 comments on commit 8d49058

Please sign in to comment.