open-nomad/helper
Tim Gross 0a19fe3b60 fix multiple overflow errors in exponential backoff (#18200)
We use capped exponential backoff in several places in the code when handling
failures. The code we've copy-and-pasted all over has a check to see if the
backoff is greater than the limit, but this check happens after the bitshift and
we always increment the number of attempts. This causes an overflow with a
fairly small number of failures (ex. at one place I tested it occurs after only
24 iterations), resulting in a negative backoff which then never recovers. The
backoff becomes a tight loop consuming resources and/or DoS'ing a Nomad RPC
handler or an external API such as Vault. Note this doesn't occur in places
where we cap the number of iterations so the loop breaks (usually to return an
error), so long as the number of iterations is reasonable.

Introduce a helper with a check on the cap before the bitshift to avoid overflow in all 
places this can occur.

Fixes: #18199
Co-authored-by: stswidwinski <stan.swidwinski@gmail.com>
2023-08-15 14:39:09 -04:00
..
args [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
boltdd Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
broker test: fix flakey broker notifier test. (#16994) 2023-05-10 13:40:25 +01:00
bufconndialer [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
codec [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
constraints/semver [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
crypto [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
discover [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
envoy connect: remove unusable path for fallback envoy image names (#17044) 2023-05-02 09:48:44 -05:00
escapingfs [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
escapingio [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
flags [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
flatmap [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
gated-writer [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
grpc-middleware/logging [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
ipaddr [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
iterator node pools: apply node pool scheduler configuration (#17598) 2023-06-21 20:31:50 -04:00
logging [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
mount [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
noxssrw [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
pluginutils Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
pointer [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
pool Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
raftutil node pool: initial base work (#17163) 2023-05-15 10:49:08 -04:00
snapshot Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
stats backport of commit 615e76ef3c23497f768ebd175f0c624d32aeece8 (#17993) 2023-07-19 13:31:14 -05:00
subproc [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
testlog [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
testtask [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
tlsutil backport of commit 8cabda5ec5c1d0dd3290ece4789cd8fea1ca3f5c (#18043) 2023-07-24 04:44:15 -05:00
useragent [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
users users: eliminate nobody user memoization (#16904) 2023-04-17 12:30:30 -05:00
uuid [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
winsvc [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
backoff.go fix multiple overflow errors in exponential backoff (#18200) 2023-08-15 14:39:09 -04:00
backoff_test.go fix multiple overflow errors in exponential backoff (#18200) 2023-08-15 14:39:09 -04:00
cluster.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
cluster_test.go update go1.21 (#18184) 2023-08-15 14:40:33 +02:00
eof.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
funcs.go update go1.21 (#18184) 2023-08-15 14:40:33 +02:00
funcs_test.go update go1.21 (#18184) 2023-08-15 14:40:33 +02:00
opaque.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
opaque_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
warning.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
warning_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00