Calls to the ec2 service must be async, and responses must be wrapped as well.
This commit is contained in:
parent
2ed9b3d243
commit
723fb27671
1 changed files with 6 additions and 6 deletions
|
@ -113,32 +113,32 @@ class EC2Executor(BuilderExecutor):
|
||||||
logger.debug('Generated cloud config: %s', user_data)
|
logger.debug('Generated cloud config: %s', user_data)
|
||||||
|
|
||||||
ec2_conn = self._get_conn()
|
ec2_conn = self._get_conn()
|
||||||
reservation = yield ec2_conn.run_instances(
|
reservation = yield From(ec2_conn.run_instances(
|
||||||
coreos_ami,
|
coreos_ami,
|
||||||
instance_type=self.executor_config['EC2_INSTANCE_TYPE'],
|
instance_type=self.executor_config['EC2_INSTANCE_TYPE'],
|
||||||
security_groups=self.executor_config['EC2_SECURITY_GROUP_IDS'],
|
security_groups=self.executor_config['EC2_SECURITY_GROUP_IDS'],
|
||||||
key_name=self.executor_config.get('EC2_KEY_NAME', None),
|
key_name=self.executor_config.get('EC2_KEY_NAME', None),
|
||||||
user_data=user_data,
|
user_data=user_data,
|
||||||
instance_initiated_shutdown_behavior='terminate',
|
instance_initiated_shutdown_behavior='terminate',
|
||||||
)
|
))
|
||||||
|
|
||||||
if not reservation.instances:
|
if not reservation.instances:
|
||||||
raise ExecutorException('Unable to spawn builder instance.')
|
raise ExecutorException('Unable to spawn builder instance.')
|
||||||
elif len(reservation.instances) != 1:
|
elif len(reservation.instances) != 1:
|
||||||
raise ExecutorException('EC2 started wrong number of instances!')
|
raise ExecutorException('EC2 started wrong number of instances!')
|
||||||
|
|
||||||
launched = reservation.instances[0]
|
launched = AsyncWrapper(reservation.instances[0])
|
||||||
launched.add_tags({
|
yield From(launched.add_tags({
|
||||||
'Name': 'Quay Ephemeral Builder',
|
'Name': 'Quay Ephemeral Builder',
|
||||||
'Realm': realm,
|
'Realm': realm,
|
||||||
'Token': token,
|
'Token': token,
|
||||||
})
|
}))
|
||||||
raise Return(launched.id)
|
raise Return(launched.id)
|
||||||
|
|
||||||
@coroutine
|
@coroutine
|
||||||
def stop_builder(self, builder_id):
|
def stop_builder(self, builder_id):
|
||||||
ec2_conn = self._get_conn()
|
ec2_conn = self._get_conn()
|
||||||
stopped_instances = yield ec2_conn.stop_instances([builder_id], force=True)
|
stopped_instances = yield From(ec2_conn.stop_instances([builder_id], force=True))
|
||||||
if builder_id not in [si.id for si in stopped_instances]:
|
if builder_id not in [si.id for si in stopped_instances]:
|
||||||
raise ExecutorException('Unable to stop instance: %s' % builder_id)
|
raise ExecutorException('Unable to stop instance: %s' % builder_id)
|
||||||
|
|
||||||
|
|
Reference in a new issue