Skip to content

Commit d0e0a1b

Browse files
authored
fix(ci3): retry on-demand fleet for up to 5m (metal bench capacity) (#24440)
## Problem The dedicated benchmark box pins `m6a.metal` (sole-tenant, to avoid co-tenant memory-bandwidth variance). Metal capacity is thin, and `create-fleet` can return `InsufficientInstanceCapacity` even on-demand. The on-demand fallback in `aws_request_instance_type` tried **once** and gave up, failing the bench run. ## Fix Wrap the on-demand fallback in a time-budgeted retry loop, mirroring the existing spot loop: - `CI_ONDEMAND_TIMEOUT` (default **300s** = 5 min), `CI_ONDEMAND_POLL` (default 20s). - Retries the whole on-demand `create-fleet` until an instance is acquired or the budget expires; logs the capacity error code per attempt. - Only reached when spot couldn't be had (unchanged), so normal spot-first behavior is untouched. ## Verification - Trigger a bench run (`ci.sh bench`) when metal capacity is tight; confirm it now retries the on-demand request (logging `InsufficientInstanceCapacity; retrying in 20s...`) rather than failing immediately, and succeeds once capacity frees within 5 min.
2 parents 02b0987 + 5e1fd38 commit d0e0a1b

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

ci3/aws_request_instance_type

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,34 @@ if [ "${NO_SPOT:-0}" -ne 1 ]; then
150150
done
151151
fi
152152

153-
# On-demand fallback (cheapest pool) only if spot couldn't be had.
153+
# On-demand fallback (cheapest pool) only if spot couldn't be had. Some pinned pools (e.g.
154+
# m6a.metal for benchmarks) can hit InsufficientInstanceCapacity even on-demand, so retry
155+
# the whole request until a time budget expires rather than giving up on the first miss.
154156
if [ -z "$iid" ]; then
155-
echo "Requesting on-demand fleet $info..."
156-
resp=$(aws ec2 create-fleet \
157-
--type instant \
158-
--target-capacity-specification "TotalTargetCapacity=1,DefaultTargetCapacityType=on-demand" \
159-
--on-demand-options "AllocationStrategy=lowest-price" \
160-
--launch-template-configs "$ltc" \
161-
--output json 2>"$state_dir/fleet_err") || true
162-
iid=$(echo "$resp" | jq -r '.Instances[0].InstanceIds[0] // empty' 2>/dev/null || true)
163-
instance_type=$(echo "$resp" | jq -r '.Instances[0].InstanceType // empty')
164-
lifecycle=ondemand
157+
ondemand_timeout=${CI_ONDEMAND_TIMEOUT:-300}
158+
ondemand_poll=${CI_ONDEMAND_POLL:-20}
159+
SECONDS=0
160+
while true; do
161+
echo "Requesting on-demand fleet $info..."
162+
resp=$(aws ec2 create-fleet \
163+
--type instant \
164+
--target-capacity-specification "TotalTargetCapacity=1,DefaultTargetCapacityType=on-demand" \
165+
--on-demand-options "AllocationStrategy=lowest-price" \
166+
--launch-template-configs "$ltc" \
167+
--output json 2>"$state_dir/fleet_err") || true
168+
iid=$(echo "$resp" | jq -r '.Instances[0].InstanceIds[0] // empty' 2>/dev/null || true)
169+
if [ -n "$iid" ]; then
170+
instance_type=$(echo "$resp" | jq -r '.Instances[0].InstanceType // empty')
171+
lifecycle=ondemand
172+
break
173+
fi
174+
if (( SECONDS + ondemand_poll >= ondemand_timeout )); then
175+
echo "On-demand fleet unfulfilled after ${ondemand_timeout}s; giving up."
176+
break
177+
fi
178+
echo "On-demand capacity unavailable$(echo "$resp" | jq -r '.Errors[0].ErrorCode // "" | if . == "" then "" else " (" + . + ")" end' 2>/dev/null); retrying in ${ondemand_poll}s (elapsed ${SECONDS}s)..."
179+
sleep "$ondemand_poll"
180+
done
165181
fi
166182

167183
if [ -z "$iid" ]; then

0 commit comments

Comments
 (0)