open-nomad/nomad/state
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
..
indexer [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
paginator [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
autopilot.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
autopilot_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
deployment_events_test.go api: enable support for setting original job source (#16763) 2023-04-11 08:45:08 -05:00
events.go node pools: add event stream support (#17412) 2023-06-06 10:14:47 -04:00
events_test.go node pools: add event stream support (#17412) 2023-06-06 10:14:47 -04:00
iterator.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
schema.go state: remove vague scaling event schema todo item. (#17610) 2023-06-20 15:22:11 +01:00
schema_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_changes.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store.go fix multiple overflow errors in exponential backoff (#18200) 2023-08-15 14:39:09 -04:00
state_store_acl.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_acl_binding_rule.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_acl_binding_rule_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_acl_sso.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_acl_sso_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_acl_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_node_pools.go node pools: namespace integration (#17562) 2023-06-16 16:30:22 -04:00
state_store_node_pools_test.go node pools: add CRUD API (#17384) 2023-06-01 15:55:49 -04:00
state_store_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_restore.go Backport of state: canonicalize namespace on restore into release/1.6.x (#18018) 2023-07-20 15:05:16 -05:00
state_store_restore_test.go job: ensure node pool is canonicalized for state restores. (#17765) 2023-06-30 07:37:22 +01:00
state_store_service_regisration_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_service_registration.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_test.go Backport of Tuning job versions retention. #17635 into release/1.6.x (#18169) 2023-08-07 13:48:09 -05:00
state_store_variables.go update go1.21 (#18184) 2023-08-15 14:40:33 +02:00
state_store_variables_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
state_store_variables_test.go state: move variables tests to use must library. (#17609) 2023-06-20 15:46:16 +01:00
testing.go Backport of Tuning job versions retention. #17635 into release/1.6.x (#18169) 2023-08-07 13:48:09 -05:00