From 6a835939b8314593f55bd25a4540ea7e73591a47 Mon Sep 17 00:00:00 2001 From: Shawn Cook Date: Tue, 18 Aug 2015 10:34:55 -0700 Subject: [PATCH] EnableTagDrift in NodeService struct --- command/agent/config_test.go | 11 +++++++++++ command/agent/local.go | 1 + command/agent/structs.go | 28 +++++++++++++++------------- consul/structs/structs.go | 11 ++++++----- testutil/server.go | 2 ++ 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index ed2a2921e0..ba84348dd2 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -683,9 +683,19 @@ func TestDecodeConfig(t *testing.T) { t.Fatalf("err: %s", err) } + // EnableTagDrift + input = `{"enable_tag_drift": true}` + config, err = DecodeConfig(bytes.NewReader([]byte(input))) + if err != nil { + t.Fatalf("err: %s", err) + } + if !config.DisableUpdateCheck { t.Fatalf("bad: %#v", config) } + if !config.EnableTagDrift { + t.Fatalf("bad: %#v", config) + } if !config.DisableAnonymousSignature { t.Fatalf("bad: %#v", config) } @@ -1189,6 +1199,7 @@ func TestMergeConfig(t *testing.T) { StatsitePrefix: "stats_prefix", StatsdAddr: "127.0.0.1:7251", DisableUpdateCheck: true, + EnableTagDrift: true, DisableAnonymousSignature: true, HTTPAPIResponseHeaders: map[string]string{ "Access-Control-Allow-Origin": "*", diff --git a/command/agent/local.go b/command/agent/local.go index dbe38e79d0..1ba9cbedc5 100644 --- a/command/agent/local.go +++ b/command/agent/local.go @@ -379,6 +379,7 @@ func (l *localState) setSyncState() error { } // If our definition is different, we need to update it + l.logger.Printf("[ERR] services: %v", service) equal := reflect.DeepEqual(existing, service) l.serviceStatus[id] = syncStatus{inSync: equal} } diff --git a/command/agent/structs.go b/command/agent/structs.go index 1d0e41e8bc..3809699eed 100644 --- a/command/agent/structs.go +++ b/command/agent/structs.go @@ -6,23 +6,25 @@ import ( // ServiceDefinition is used to JSON decode the Service definitions type ServiceDefinition struct { - ID string - Name string - Tags []string - Address string - Port int - Check CheckType - Checks CheckTypes - Token string + ID string + Name string + Tags []string + Address string + Port int + Check CheckType + Checks CheckTypes + Token string + EnableTagDrift bool } func (s *ServiceDefinition) NodeService() *structs.NodeService { ns := &structs.NodeService{ - ID: s.ID, - Service: s.Name, - Tags: s.Tags, - Address: s.Address, - Port: s.Port, + ID: s.ID, + Service: s.Name, + Tags: s.Tags, + Address: s.Address, + Port: s.Port, + EnableTagDrift: s.EnableTagDrift, } if ns.ID == "" && ns.Service != "" { ns.ID = ns.Service diff --git a/consul/structs/structs.go b/consul/structs/structs.go index 60d980028a..ec1976bf79 100644 --- a/consul/structs/structs.go +++ b/consul/structs/structs.go @@ -245,11 +245,12 @@ type ServiceNodes []ServiceNode // NodeService is a service provided by a node type NodeService struct { - ID string - Service string - Tags []string - Address string - Port int + ID string + Service string + Tags []string + Address string + Port int + EnableTagDrift bool } type NodeServices struct { Node Node diff --git a/testutil/server.go b/testutil/server.go index 66b4f95097..c02317effe 100644 --- a/testutil/server.go +++ b/testutil/server.go @@ -55,6 +55,7 @@ type TestServerConfig struct { DataDir string `json:"data_dir,omitempty"` Datacenter string `json:"datacenter,omitempty"` DisableCheckpoint bool `json:"disable_update_check"` + EnableTagDrift bool `json:"enable_tag_drift"` LogLevel string `json:"log_level,omitempty"` Bind string `json:"bind_addr,omitempty"` Addresses *TestAddressConfig `json:"addresses,omitempty"` @@ -77,6 +78,7 @@ func defaultServerConfig() *TestServerConfig { return &TestServerConfig{ NodeName: fmt.Sprintf("node%d", idx), DisableCheckpoint: true, + EnableTagDrift: true, Bootstrap: true, Server: true, LogLevel: "debug",