From 3cf1a64f879e380909f7cf685b0100a639ada9ad Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 5 Mar 2014 15:03:23 -0800 Subject: [PATCH] agent: Handle API changes --- command/agent/dns.go | 2 +- command/agent/local.go | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/command/agent/dns.go b/command/agent/dns.go index 6ef5b6cc63..d1107a241c 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -308,7 +308,7 @@ func (d *DNSServer) nodeLookup(network, datacenter, node string, req, resp *dns. } // If we have no address, return not found! - if out.NodeServices.Node.Address == "" { + if out.NodeServices == nil { resp.SetRcode(req, dns.RcodeNameError) return } diff --git a/command/agent/local.go b/command/agent/local.go index 671b6e1eac..bf97bcece4 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -276,22 +276,24 @@ func (l *localState) setSyncState() error { l.Lock() defer l.Unlock() - for id, service := range services.Services { - // If we don't have the service locally, deregister it - existing, ok := l.services[id] - if !ok { - // The Consul service is created automatically, and - // does not need to be registered - if id == consul.ConsulServiceID && l.config.Server { + if services != nil { + for id, service := range services.Services { + // If we don't have the service locally, deregister it + existing, ok := l.services[id] + if !ok { + // The Consul service is created automatically, and + // does not need to be registered + if id == consul.ConsulServiceID && l.config.Server { + continue + } + l.serviceStatus[id] = syncStatus{remoteDelete: true} continue } - l.serviceStatus[id] = syncStatus{remoteDelete: true} - 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 _, check := range checks {