Skip to content

Commit

Permalink
Merge pull request #4390 from jrasell/f_gh_4381
Browse files Browse the repository at this point in the history
Add 'nomad.advertise.address' to client meta via NomadFingerPrint
  • Loading branch information
preetapan committed Jun 20, 2018
2 parents 6e99364 + 46037d7 commit 3ed221b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/fingerprint/nomad.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func NewNomadFingerprint(logger *log.Logger) Fingerprint {
}

func (f *NomadFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
resp.AddAttribute("nomad.advertise.address", req.Node.HTTPAddr)
resp.AddAttribute("nomad.version", req.Config.Version.VersionNumber())
resp.AddAttribute("nomad.revision", req.Config.Version.Revision)
resp.Detected = true
Expand Down
13 changes: 10 additions & 3 deletions client/fingerprint/nomad_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@ import (

func TestNomadFingerprint(t *testing.T) {
f := NewNomadFingerprint(testlog.Logger(t))
node := &structs.Node{
Attributes: make(map[string]string),
}

v := "foo"
r := "123"
h := "8.8.8.8:4646"
c := &config.Config{
Version: &version.VersionInfo{
Revision: r,
Version: v,
},
}
node := &structs.Node{
Attributes: make(map[string]string),
HTTPAddr: h,
}

request := &cstructs.FingerprintRequest{Config: c, Node: node}
var response cstructs.FingerprintResponse
Expand All @@ -46,4 +49,8 @@ func TestNomadFingerprint(t *testing.T) {
if response.Attributes["nomad.revision"] != r {
t.Fatalf("incorrect revision")
}

if response.Attributes["nomad.advertise.address"] != h {
t.Fatalf("incorrect advertise address")
}
}

0 comments on commit 3ed221b

Please sign in to comment.