diff --git a/buildman/manager/executor.py b/buildman/manager/executor.py index 9853887f5..3e6034f0d 100644 --- a/buildman/manager/executor.py +++ b/buildman/manager/executor.py @@ -14,6 +14,7 @@ from functools import partial from buildman.asyncutil import AsyncWrapper from container_cloud_config import CloudConfigContext +from app import metric_queue logger = logging.getLogger(__name__) @@ -136,15 +137,20 @@ class EC2Executor(BuilderExecutor): ) interfaces = boto.ec2.networkinterface.NetworkInterfaceCollection(interface) - reservation = yield From(ec2_conn.run_instances( - coreos_ami, - instance_type=self.executor_config['EC2_INSTANCE_TYPE'], - key_name=self.executor_config.get('EC2_KEY_NAME', None), - user_data=user_data, - instance_initiated_shutdown_behavior='terminate', - block_device_map=block_devices, - network_interfaces=interfaces, - )) + try: + reservation = yield From(ec2_conn.run_instances( + coreos_ami, + instance_type=self.executor_config['EC2_INSTANCE_TYPE'], + key_name=self.executor_config.get('EC2_KEY_NAME', None), + user_data=user_data, + instance_initiated_shutdown_behavior='terminate', + block_device_map=block_devices, + network_interfaces=interfaces, + )) + except boto.exception.EC2ResponseError as ec2e: + logger.exception('Unable to spawn builder instance') + metric_queue.put('EC2BuildStartFailure', 1, unit='Count') + raise ec2e if not reservation.instances: raise ExecutorException('Unable to spawn builder instance.')