mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
agent: remove service sidecars in Agent.cleanupRegistration (#7022)
Sidecar proxies were left behind when cleaning up after an unsuccessful registration. There are now also removed when the service is cleanup up.
This commit is contained in:
parent
9c1361c02b
commit
8fc736038a
@ -2519,6 +2519,9 @@ func (a *Agent) cleanupRegistration(serviceIDs []structs.ServiceID, checksIDs []
|
||||
if err := a.purgeServiceConfig(s); err != nil {
|
||||
a.logger.Printf("[ERR] consul: service registration: cleanup: failed to purge service config %s file: %s", s, err)
|
||||
}
|
||||
if err := a.removeServiceSidecars(s, true); err != nil {
|
||||
a.logger.Printf("[ERR] consul: service registration: cleanup: failed remove sidecars for %s: %s", s, err)
|
||||
}
|
||||
}
|
||||
|
||||
for _, c := range checksIDs {
|
||||
@ -2599,6 +2602,10 @@ func (a *Agent) removeServiceLocked(serviceID structs.ServiceID, persist bool) e
|
||||
a.logger.Printf("[DEBUG] agent: removed service %q", serviceID.String())
|
||||
|
||||
// If any Sidecar services exist for the removed service ID, remove them too.
|
||||
return a.removeServiceSidecars(serviceID, persist)
|
||||
}
|
||||
|
||||
func (a *Agent) removeServiceSidecars(serviceID structs.ServiceID, persist bool) error {
|
||||
var sidecarSID structs.ServiceID
|
||||
sidecarSID.Init(a.sidecarServiceID(serviceID.ID), &serviceID.EnterpriseMeta)
|
||||
if sidecar := a.State.Service(sidecarSID); sidecar != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user