Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3182)

Unified Diff: appengine/swarming/swarming_bot/api/os_utilities.py

Issue 2801033003: Avoid key error for custom machine types (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/swarming_bot/api/os_utilities.py
diff --git a/appengine/swarming/swarming_bot/api/os_utilities.py b/appengine/swarming/swarming_bot/api/os_utilities.py
index b95d7fec21f530bd70014facc7f226f1fb4ca9c8..28710d916c0135d0bbd602314a48aaca87677906 100644
--- a/appengine/swarming/swarming_bot/api/os_utilities.py
+++ b/appengine/swarming/swarming_bot/api/os_utilities.py
@@ -412,9 +412,9 @@ def get_cost_hour():
machine_type = get_machine_type()
if platforms.is_gce():
if platforms.gce.get_zone().startswith('us-'):
- machine_cost = GCE_MACHINE_COST_HOUR_US[machine_type]
+ machine_cost = GCE_MACHINE_COST_HOUR_US.get(machine_type, 0.)
borenet 2017/04/07 12:19:25 I suspect we'll want a default, eg. GCE_MACHINE_CO
M-A Ruel 2017/04/07 12:20:16 Bah, I prefer 0 than something really wrong. I don
else:
- machine_cost = GCE_MACHINE_COST_HOUR_EUROPE_ASIA[machine_type]
+ machine_cost = GCE_MACHINE_COST_HOUR_EUROPE_ASIA.get(machine_type, 0.)
else:
# Guess an equivalent machine_type.
machine_cost = GCE_MACHINE_COST_HOUR_US.get(machine_type, 0.)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698