Skip to content

Commit

Permalink
Backport of fingerprint: only log failed Consul fingerprint once into…
Browse files Browse the repository at this point in the history
… release/1.9.x (#25183)

Co-authored-by: Tim Gross <[email protected]>
  • Loading branch information
hc-github-team-nomad-core and tgross authored Feb 21, 2025
1 parent 6cfbf44 commit d439573
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/fingerprint/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ type consulState struct {
// tracks that we've successfully fingerprinted this cluster at least once
// since the last Fingerprint call
fingerprintedOnce bool

// we currently can't disable Consul fingerprinting, so for users who aren't
// using it we want to make sure we report the periodic failure only once
reportedOnce bool
}

// valueReader is used to parse out one attribute from consulInfo. Returns
Expand Down Expand Up @@ -225,9 +229,15 @@ func (cfs *consulState) query(logger hclog.Logger) agentconsul.Self {
// If we can't hit this URL consul is probably not running on this machine.
info, err := cfs.client.Agent().Self()
if err != nil {
if cfs.reportedOnce {
return nil
}
cfs.reportedOnce = true
logger.Warn("failed to acquire consul self endpoint", "error", err)
return nil
}

cfs.reportedOnce = false
return info
}

Expand Down

0 comments on commit d439573

Please sign in to comment.