mirror of https://github.com/hashicorp/consul
agent: handle nil node services in anti-entropy
parent
7e170b047e
commit
60a6da213f
|
@ -310,32 +310,34 @@ func (l *localState) setSyncState() error {
|
||||||
if err := l.iface.RPC("Health.NodeChecks", &req, &out2); err != nil {
|
if err := l.iface.RPC("Health.NodeChecks", &req, &out2); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
services := out1.NodeServices
|
|
||||||
checks := out2.HealthChecks
|
checks := out2.HealthChecks
|
||||||
|
|
||||||
l.Lock()
|
l.Lock()
|
||||||
defer l.Unlock()
|
defer l.Unlock()
|
||||||
|
|
||||||
|
services := make(map[string]*structs.NodeService)
|
||||||
|
if out1.NodeServices != nil {
|
||||||
|
services = out1.NodeServices.Services
|
||||||
|
}
|
||||||
|
|
||||||
for id, _ := range l.services {
|
for id, _ := range l.services {
|
||||||
// If the local service doesn't exist remotely, then sync it
|
// If the local service doesn't exist remotely, then sync it
|
||||||
if _, ok := services.Services[id]; !ok {
|
if _, ok := services[id]; !ok {
|
||||||
l.serviceStatus[id] = syncStatus{inSync: false}
|
l.serviceStatus[id] = syncStatus{inSync: false}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if services != nil {
|
for id, service := range services {
|
||||||
for id, service := range services.Services {
|
// If we don't have the service locally, deregister it
|
||||||
// If we don't have the service locally, deregister it
|
existing, ok := l.services[id]
|
||||||
existing, ok := l.services[id]
|
if !ok {
|
||||||
if !ok {
|
l.serviceStatus[id] = syncStatus{remoteDelete: true}
|
||||||
l.serviceStatus[id] = syncStatus{remoteDelete: true}
|
continue
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// If our definition is different, we need to update it
|
|
||||||
equal := reflect.DeepEqual(existing, service)
|
|
||||||
l.serviceStatus[id] = syncStatus{inSync: equal}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If our definition is different, we need to update it
|
||||||
|
equal := reflect.DeepEqual(existing, service)
|
||||||
|
l.serviceStatus[id] = syncStatus{inSync: equal}
|
||||||
}
|
}
|
||||||
|
|
||||||
for id, _ := range l.checks {
|
for id, _ := range l.checks {
|
||||||
|
|
Loading…
Reference in New Issue