Skip to content

Commit

Permalink
factor out failed to start situation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sobolev committed Mar 24, 2015
1 parent 52435df commit 393611d
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions master/buildbot/buildslave/ec2.py
Expand Up @@ -279,6 +279,13 @@ def start_instance(self, build):
else:
return threads.deferToThread(self._start_instance)

def _failed_to_start(self):
log.msg('%s %s failed to start instance %s (%s)' %
(self.__class__.__name__, self.slavename,
self.instance.id, self.instance.state))
raise interfaces.LatentBuildSlaveFailedToSubstantiate(
self.instance.id, self.instance.state)

def _start_instance(self):
image = self.get_image()
reservation = image.run(
Expand All @@ -293,11 +300,7 @@ def _start_instance(self):
self.conn.create_tags(instance_id, self.tags)
return [instance_id, image_id, start_time]
else:
log.msg('%s %s failed to start instance %s (%s)' %
(self.__class__.__name__, self.slavename,
self.instance.id, self.instance.state))
raise interfaces.LatentBuildSlaveFailedToSubstantiate(
self.instance.id, self.instance.state)
self._failed_to_start()

def stop_instance(self, fast=False):
if self.instance is None:
Expand Down Expand Up @@ -442,11 +445,7 @@ def _wait_for_instance(self, image):
self._attach_volumes()
return self.instance.id, image.id, start_time
else:
log.msg('%s %s failed to start instance %s (%s)' %
(self.__class__.__name__, self.slavename,
self.instance.id, self.instance.state))
raise interfaces.LatentBuildSlaveFailedToSubstantiate(
self.instance.id, self.instance.state)
self._failed_to_start()

def _wait_for_request(self, reservation):
duration = 0
Expand Down

0 comments on commit 393611d

Please sign in to comment.