From 98fffdacb547b27093d09f2d471122d68b3c1986 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 5 Mar 2014 15:03:12 -0800 Subject: [PATCH] consul: Handle API changes in StateStore --- consul/fsm_test.go | 2 +- consul/leader.go | 8 +++++--- consul/state_store_test.go | 5 ++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/consul/fsm_test.go b/consul/fsm_test.go index ea94eb6d29..5c210db06e 100644 --- a/consul/fsm_test.go +++ b/consul/fsm_test.go @@ -290,7 +290,7 @@ func TestFSM_DeregisterNode(t *testing.T) { // Verify service not registered _, services := fsm.state.NodeServices("foo") - if len(services.Services) != 0 { + if services != nil { t.Fatalf("Services: %v", services) } diff --git a/consul/leader.go b/consul/leader.go index 94a8458d27..53a30d3224 100644 --- a/consul/leader.go +++ b/consul/leader.go @@ -174,9 +174,11 @@ func (s *Server) handleAliveMember(member serf.Member) error { if service != nil { match := false _, services := state.NodeServices(member.Name) - for id, _ := range services.Services { - if id == service.ID { - match = true + if services != nil { + for id, _ := range services.Services { + if id == service.ID { + match = true + } } } if !match { diff --git a/consul/state_store_test.go b/consul/state_store_test.go index da213d639b..de5ccd8058 100644 --- a/consul/state_store_test.go +++ b/consul/state_store_test.go @@ -302,9 +302,8 @@ func TestDeleteNode(t *testing.T) { if idx != 23 { t.Fatalf("bad: %v", idx) } - _, ok := services.Services["api"] - if ok { - t.Fatalf("has api: %#v", services) + if services != nil { + t.Fatalf("has services: %#v", services) } idx, checks := store.NodeChecks("foo")