From 21fbe3e011d57bb79014cd255d6c47a308f694b5 Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Mon, 7 Nov 2022 16:53:25 +0100 Subject: [PATCH] server: add git revision to serf tags (#9159) (#15172) Co-authored-by: Drew Gonzales <6912711+drewgonzales360@users.noreply.github.com> --- .changelog/9159.txt | 3 +++ command/agent/agent.go | 1 + nomad/config.go | 4 ++++ nomad/server.go | 1 + 4 files changed, 9 insertions(+) create mode 100644 .changelog/9159.txt diff --git a/.changelog/9159.txt b/.changelog/9159.txt new file mode 100644 index 000000000000..cb05e56b7e42 --- /dev/null +++ b/.changelog/9159.txt @@ -0,0 +1,3 @@ +```release-note:improvement +server: Add a git `revision` tag to the serf tags gossiped between servers. +``` diff --git a/command/agent/agent.go b/command/agent/agent.go index cea21eb6c026..21ea97475ba2 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -171,6 +171,7 @@ func convertServerConfig(agentConfig *Config) (*nomad.Config, error) { conf.EnableDebug = agentConfig.EnableDebug conf.Build = agentConfig.Version.VersionNumber() + conf.Revision = agentConfig.Version.Revision if agentConfig.Region != "" { conf.Region = agentConfig.Region } diff --git a/nomad/config.go b/nomad/config.go index 1161dc4421d4..7014ef987fe5 100644 --- a/nomad/config.go +++ b/nomad/config.go @@ -128,6 +128,10 @@ type Config struct { // operators track which versions are actively deployed Build string + // Revision is a string that carries the version.GitCommit of Nomad that + // was compiled. + Revision string + // NumSchedulers is the number of scheduler thread that are run. // This can be as many as one per core, or zero to disable this server // from doing any scheduling work. diff --git a/nomad/server.go b/nomad/server.go index 32df0f448b70..40fee1b4fe36 100644 --- a/nomad/server.go +++ b/nomad/server.go @@ -1517,6 +1517,7 @@ func (s *Server) setupSerf(conf *serf.Config, ch chan serf.Event, path string) ( conf.Tags["region"] = s.config.Region conf.Tags["dc"] = s.config.Datacenter conf.Tags["build"] = s.config.Build + conf.Tags["revision"] = s.config.Revision conf.Tags["vsn"] = deprecatedAPIMajorVersionStr // for Nomad <= v1.2 compat conf.Tags["raft_vsn"] = fmt.Sprintf("%d", s.config.RaftConfig.ProtocolVersion) conf.Tags["id"] = s.config.NodeID