Skip to content

Commit

Permalink
ci: select_machine: Fix crash when m3.large.x86 is unavailable
Browse files Browse the repository at this point in the history
Not all machines are available in all locations.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
  • Loading branch information
kdrag0n committed May 3, 2021
1 parent 7894868 commit 0682c36
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ci/select_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@

def check_locations(prices, max_price, locations):
for loc in locations:
# Not all machines are available in all locations
if loc not in prices:
continue

# Intrinsic: $XX.01 == market full and request will not be fulfilled
price_fract = prices[loc] - round(prices[loc])
market_full = price_fract >= 0.0095 and price_fract <= 0.015
Expand All @@ -50,7 +54,9 @@ def select_machine():
data = r.json()["spot_market_prices"]

prices = {loc: list(matches.values())[0]["price"] for loc, matches in data.items()}
max_price = ondemand_price * 4 # 10x == no spot market capacity available, but it's closer to 4x for g2.large (+ 0.01)
# 10x == no spot market capacity available, but it's closer to 4x for g2.large (+ 0.01)
max_price = ondemand_price * 4

location, price = check_locations(prices, max_price, preferred_locations)
if location:
return {
Expand Down

0 comments on commit 0682c36

Please sign in to comment.