Skip to content

Commit 833223a

Browse files
committed
Ensure we remove Connect proxy before deregistering the service itself
This will fix hashicorp#5351
1 parent 23bc863 commit 833223a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

agent/agent.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,17 @@ func (a *Agent) removeServiceLocked(serviceID string, persist bool) error {
20712071
checkIDs = append(checkIDs, id)
20722072
}
20732073

2074+
// Remove the associated managed proxy if it exists
2075+
// This has to be DONE before purging configuration as might might have issues
2076+
// With ACLs otherwise
2077+
for proxyID, p := range a.State.Proxies() {
2078+
if p.Proxy.TargetServiceID == serviceID {
2079+
if err := a.removeProxyLocked(proxyID, true); err != nil {
2080+
return err
2081+
}
2082+
}
2083+
}
2084+
20742085
// Remove service immediately
20752086
if err := a.State.RemoveServiceWithChecks(serviceID, checkIDs); err != nil {
20762087
a.logger.Printf("[WARN] agent: Failed to deregister service %q: %s", serviceID, err)
@@ -2094,15 +2105,6 @@ func (a *Agent) removeServiceLocked(serviceID string, persist bool) error {
20942105
}
20952106
}
20962107

2097-
// Remove the associated managed proxy if it exists
2098-
for proxyID, p := range a.State.Proxies() {
2099-
if p.Proxy.TargetServiceID == serviceID {
2100-
if err := a.removeProxyLocked(proxyID, true); err != nil {
2101-
return err
2102-
}
2103-
}
2104-
}
2105-
21062108
a.logger.Printf("[DEBUG] agent: removed service %q", serviceID)
21072109

21082110
// If any Sidecar services exist for the removed service ID, remove them too.

0 commit comments

Comments
 (0)