Skip to content

Commit

Permalink
fingerprint: eliminate spurious warning logs with Consul CE
Browse files Browse the repository at this point in the history
Support for fingerprinting the Consul admin partition was added in #19485. But
when the client fingerprints Consul CE, it gets a valid fingerprint and working
Consul but with a warn-level log. Return "ok" from the partition extractor, but
also ensure that we only add the Consul attribute if it actually has a value.

Fixes: #19756
  • Loading branch information
tgross committed Feb 8, 2024
1 parent 41c783a commit 587a270
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions client/fingerprint/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (f *ConsulFingerprint) fingerprintImpl(cfg *config.ConsulConfig, resp *Fing
for attr, extractor := range state.extractors {
if s, ok := extractor(info); !ok {
logger.Warn("unable to fingerprint consul", "attribute", attr)
} else {
} else if s != "" {
resp.AddAttribute(attr, s)
}
}
Expand Down Expand Up @@ -311,5 +311,5 @@ func (cfs *consulFingerprintState) partition(info agentconsul.Self) (string, boo
}
return p, true
}
return "", false
return "", true // prevent warnings on Consul CE
}
6 changes: 3 additions & 3 deletions client/fingerprint/consul_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func TestConsulFingerprint_partition(t *testing.T) {
p, ok := cfs.partition(agentconsul.Self{
"Config": {"Version": "v1.9.5"},
})
must.False(t, ok)
must.True(t, ok)
must.Eq(t, "", p)
})

Expand All @@ -478,15 +478,15 @@ func TestConsulFingerprint_partition(t *testing.T) {
p, ok := cfs.partition(agentconsul.Self{
"Config": {},
})
must.False(t, ok)
must.True(t, ok)
must.Eq(t, "", p)
})

t.Run("malformed", func(t *testing.T) {
p, ok := cfs.partition(agentconsul.Self{
"Config": {"Version": "***"},
})
must.False(t, ok)
must.True(t, ok)
must.Eq(t, "", p)
})
}
Expand Down

0 comments on commit 587a270

Please sign in to comment.