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)
|
||||
|
||||
ec2_conn = self._get_conn()
|
||||
reservation = yield ec2_conn.run_instances(
|
||||
reservation = yield From(ec2_conn.run_instances(
|
||||
coreos_ami,
|
||||
instance_type=self.executor_config['EC2_INSTANCE_TYPE'],
|
||||
security_groups=self.executor_config['EC2_SECURITY_GROUP_IDS'],
|
||||
key_name=self.executor_config.get('EC2_KEY_NAME', None),
|
||||
user_data=user_data,
|
||||
instance_initiated_shutdown_behavior='terminate',
|
||||
)
|
||||
))
|
||||
|
||||
if not reservation.instances:
|
||||
raise ExecutorException('Unable to spawn builder instance.')
|
||||
elif len(reservation.instances) != 1:
|
||||
raise ExecutorException('EC2 started wrong number of instances!')
|
||||
|
||||
launched = reservation.instances[0]
|
||||
launched.add_tags({
|
||||
launched = AsyncWrapper(reservation.instances[0])
|
||||
yield From(launched.add_tags({
|
||||
'Name': 'Quay Ephemeral Builder',
|
||||
'Realm': realm,
|
||||
'Token': token,
|
||||
})
|
||||
}))
|
||||
raise Return(launched.id)
|
||||
|
||||
@coroutine
|
||||
def stop_builder(self, builder_id):
|
||||
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]:
|
||||
raise ExecutorException('Unable to stop instance: %s' % builder_id)
|
||||
|
||||
|
|
Reference in a new issue