fix etcd bug that causes deregister to be skipped (#1911)

This commit is contained in:
Asim Aslam 2020-08-07 19:58:25 +01:00 committed by GitHub
parent a6d7b1d710
commit d69a4a30cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -366,9 +366,18 @@ func (e *etcdRegistry) Deregister(s *registry.Service, opts ...registry.Deregist
for _, node := range s.Nodes { for _, node := range s.Nodes {
e.Lock() e.Lock()
// delete our hash of the service // delete our hash of the service
delete(e.register, s.Name+node.Id) nodes, ok := e.register[options.Domain]
if ok {
delete(nodes, s.Name+node.Id)
e.register[options.Domain] = nodes
}
// delete our lease of the service // delete our lease of the service
delete(e.leases, s.Name+node.Id) leases, ok := e.leases[options.Domain]
if ok {
delete(leases, s.Name+node.Id)
e.leases[options.Domain] = leases
}
e.Unlock() e.Unlock()
ctx, cancel := context.WithTimeout(context.Background(), e.options.Timeout) ctx, cancel := context.WithTimeout(context.Background(), e.options.Timeout)