Skip to content

Commit

Permalink
fingerprint: only log failed Consul fingerprint once (#25182)
Browse files Browse the repository at this point in the history
In #24526 we updated Consul and Vault fingerprinting so that we no longer
periodically fingerprint. In #25102 we made it so that we fingerprint
periodically on start until the first fingerprint, in order to tolerate Consul
or Vault not being available on start. For clusters not running Consul, this
leads to a warn-level log every 15s. This same log exists for Vault, but Vault
support is opt-in via `vault.enable = true` whereas you have to manually disable
the fingerprinter for Consul.

Make it so that we only log a failed Consul fingerprint once per Consul
cluster. Reset the gate on this once we have a successful fingerprint, so that
we get the logs after a reload if Consul is unavailable.

Ref: #24526
Ref: #25102
Fixes: #25181
  • Loading branch information
tgross authored Feb 21, 2025
1 parent 5c7e3bb commit e02ef73
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 e02ef73

Please sign in to comment.