diff --git a/command/agent/agent.go b/command/agent/agent.go index 5cf79cdabc..77733bdc89 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 9987552405..5b1ea29467 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 d75f229f1c..198ce53f50 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 c7c8062f1c..0a29504c3d 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"