agent/checks: prevent overflow of backoff

This commit is contained in:
Mitchell Hashimoto 2018-07-12 10:21:49 -07:00
parent d6ecd97d1d
commit 9a90400821
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
1 changed files with 5 additions and 1 deletions

View File

@ -120,7 +120,11 @@ func (c *CheckAlias) runQuery(stopCh chan struct{}) {
// Backoff if we have to
if attempt > checkAliasBackoffMin {
waitTime := (1 << (attempt - checkAliasBackoffMin)) * time.Second
shift := attempt - checkAliasBackoffMin
if shift > 31 {
shift = 31 // so we don't overflow to 0
}
waitTime := (1 << shift) * time.Second
if waitTime > checkAliasBackoffMaxWait {
waitTime = checkAliasBackoffMaxWait
}