From b5bd20634abb96c353a3b84f3482d1456138bbf6 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 6 Jun 2014 15:36:40 -0700 Subject: [PATCH] consul: Gossip the build using Serf --- command/agent/agent.go | 8 ++++++++ consul/client.go | 1 + consul/config.go | 4 ++++ consul/server.go | 1 + 4 files changed, 14 insertions(+) diff --git a/command/agent/agent.go b/command/agent/agent.go index 5cf79cdab..77733bdc8 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -175,6 +175,14 @@ func (a *Agent) consulConfig() *consul.Config { base.ProtocolVersion = uint8(a.config.Protocol) } + // Format the build string + revision := a.config.Revision + if len(revision) > 8 { + revision = revision[:8] + } + base.Build = fmt.Sprintf("%s%s:%s", + a.config.Version, a.config.VersionPrerelease, revision) + // Copy the TLS configuration base.VerifyIncoming = a.config.VerifyIncoming base.VerifyOutgoing = a.config.VerifyOutgoing diff --git a/consul/client.go b/consul/client.go index 998755240..5b1ea2946 100644 --- a/consul/client.go +++ b/consul/client.go @@ -128,6 +128,7 @@ func (c *Client) setupSerf(conf *serf.Config, ch chan serf.Event, path string) ( conf.Tags["vsn"] = fmt.Sprintf("%d", c.config.ProtocolVersion) conf.Tags["vsn_min"] = fmt.Sprintf("%d", ProtocolVersionMin) conf.Tags["vsn_max"] = fmt.Sprintf("%d", ProtocolVersionMax) + conf.Tags["build"] = c.config.Build conf.MemberlistConfig.LogOutput = c.config.LogOutput conf.LogOutput = c.config.LogOutput conf.EventCh = ch diff --git a/consul/config.go b/consul/config.go index d75f229f1..198ce53f5 100644 --- a/consul/config.go +++ b/consul/config.go @@ -115,6 +115,10 @@ type Config struct { // true, we ignore the leave, and rejoin the cluster on start. RejoinAfterLeave bool + // Build is a string that is gossiped around, and can be used to help + // operators track which versions are actively deployed + Build string + // ServerUp callback can be used to trigger a notification that // a Consul server is now up and known about. ServerUp func() diff --git a/consul/server.go b/consul/server.go index c7c8062f1..0a29504c3 100644 --- a/consul/server.go +++ b/consul/server.go @@ -224,6 +224,7 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string, w conf.Tags["vsn"] = fmt.Sprintf("%d", s.config.ProtocolVersion) conf.Tags["vsn_min"] = fmt.Sprintf("%d", ProtocolVersionMin) conf.Tags["vsn_max"] = fmt.Sprintf("%d", ProtocolVersionMax) + conf.Tags["build"] = s.config.Build conf.Tags["port"] = fmt.Sprintf("%d", addr.Port) if s.config.Bootstrap { conf.Tags["bootstrap"] = "1"