Bug 1315441 - Handle missing aws_instance_type key; r?ted
The previous code threw and logged an exception. TreeHerder found
this (harmless) warning and reported it as something more dangerous.
So handle the missing key without raising.
MozReview-Commit-ID: 4zBHrgBBXpe
--- a/testing/mozharness/mozharness/base/python.py
+++ b/testing/mozharness/mozharness/base/python.py
@@ -511,17 +511,17 @@ class PerfherderResourceOptionsMixin(Scr
# Try to load EC2 instance type from metadata file. This file
# may not exist in many scenarios (including when inside a chroot).
# So treat it as optional.
# TODO support Windows.
try:
# This file should exist on Linux in EC2.
with open('/etc/instance_metadata.json', 'rb') as fh:
im = json.load(fh)
- instance = im['aws_instance_type'].encode('ascii')
+ instance = im.get('aws_instance_type', u'unknown').encode('ascii')
except IOError as e:
if e.errno != errno.ENOENT:
raise
self.info('instance_metadata.json not found; unable to '
'determine instance type')
except Exception:
self.warning('error reading instance_metadata: %s' %
traceback.format_exc())