Skip to content

Commit 53e3304

Browse files
author
Noah Meyerhans
committed
Set max-time values for all curl calls
Curl should normally complete very quickly, but we'll still go with a long (5s) max time in order to cope with underprovisioned and/or overloaded instances.
1 parent e89785f commit 53e3304

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/lib.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ get_token() {
3838
while [ "$(date +%s)" -lt $deadline ]; do
3939
for ep in "${imds_endpoints[@]}"; do
4040
set +e
41-
imds_token=$(curl --connect-timeout 0.15 -s --fail \
41+
imds_token=$(curl --max-time 5 --connect-timeout 0.15 -s --fail \
4242
-X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 60" ${ep}/${imds_token_path})
4343
set -e
4444
if [ -n "$imds_token" ]; then
@@ -83,7 +83,7 @@ get_meta() {
8383
local url="${imds_endpoint}/meta-data/${key}"
8484
local meta rc
8585
while [ $attempts -lt $max_tries ]; do
86-
meta=$(curl -s -H "X-aws-ec2-metadata-token:${imds_token}" -f "$url")
86+
meta=$(curl -s --max-time 5 -H "X-aws-ec2-metadata-token:${imds_token}" -f "$url")
8787
rc=$?
8888
if [ $rc -eq 0 ]; then
8989
echo "$meta"

0 commit comments

Comments
 (0)