open-nomad/command/agent
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
..
consul fix multiple overflow errors in exponential backoff (#18200) 2023-08-15 14:39:09 -04:00
event [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
host [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
monitor [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
pprof [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
test-resources [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
testdata [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
acl_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
acl_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
agent.go Backport of Tuning job versions retention. #17635 into release/1.6.x (#18169) 2023-08-07 13:48:09 -05:00
agent_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
agent_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
agent_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
agent_test.go cli: tls certs not created with correct SANs (#16959) 2023-05-22 09:31:56 -04:00
alloc_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
alloc_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
bindata_assetfs.go Generate files for 1.6.1 release 2023-07-21 13:49:42 +00:00
command.go node pool: node pool upsert on multiregion node register (#17503) 2023-06-13 11:28:28 -04:00
command_test.go Add check for missing `path` in client `host_volume` config (#17393) 2023-06-05 19:31:19 -04:00
config.go Backport of Tuning job versions retention. #17635 into release/1.6.x (#18169) 2023-08-07 13:48:09 -05:00
config_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
config_parse.go conf: Add preemption_config to the server extra HCL keys which should be removed (#17481) 2023-06-13 10:48:19 +02:00
config_parse_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
config_test.go node pools: register a node in a node pool (#17405) 2023-06-02 17:50:50 -04:00
csi_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
csi_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
deployment_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
deployment_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
eval_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
eval_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
event_endpoint.go Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
event_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
fs_endpoint.go Revert "hashicorp/go-msgpack v2 (#16810)" (#17047) 2023-05-01 17:18:34 -04:00
fs_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
helpers.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
helpers_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
http.go config: add configurable content security policy (#18085) 2023-08-14 14:25:21 -04:00
http_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
http_stdlog.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
http_stdlog_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
http_test.go update go1.21 (#18184) 2023-08-15 14:40:33 +02:00
job_endpoint.go Backport of feature: Add new field render_templates on restart block into release/1.6.x (#18094) 2023-07-28 13:54:00 -05:00
job_endpoint_test.go Backport of feature: Add new field render_templates on restart block into release/1.6.x (#18094) 2023-07-28 13:54:00 -05:00
keyring.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
keyring_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
keyring_endpoint_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
keyring_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_file.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_file_bsd.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_file_linux.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_file_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_file_windows.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_levels.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
log_levels_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
meta_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
metrics_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
metrics_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
namespace_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
namespace_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
node_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
node_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
node_pool_endpoint.go backport of commit b7d14f133c69a64e39c40417705d29b6f2b96f60 (#18065) 2023-07-26 08:23:49 -05:00
node_pool_endpoint_test.go backport of commit b7d14f133c69a64e39c40417705d29b6f2b96f60 (#18065) 2023-07-26 08:23:49 -05:00
operator_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
operator_endpoint_oss.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
operator_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
plugins.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
plugins_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
region_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
region_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
retry_join.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
retry_join_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
scaling_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
scaling_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
search_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
search_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
service_registration_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
service_registration_endpoint_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
stats_endpoint.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
stats_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
status_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
status_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
stub_asset.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
syslog.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
syslog_test.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
system_endpoint.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
system_endpoint_test.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
testagent.go chore(lint): use Go stdlib variables for HTTP methods and status codes (#17968) (#18074) 2023-07-26 16:38:39 +01:00
testagent_oss.go [COMPLIANCE] Add Copyright and License Headers 2023-04-10 15:36:59 +00:00
testingutils_test.go Backport of feature: Add new field render_templates on restart block into release/1.6.x (#18094) 2023-07-28 13:54:00 -05:00
variable_endpoint.go backport of commit 14102979762cc48183cd70dc91e26c08f630ab9d (#18067) 2023-07-26 08:30:35 -05:00
variable_endpoint_test.go backport of commit 14102979762cc48183cd70dc91e26c08f630ab9d (#18067) 2023-07-26 08:30:35 -05:00