Skip to content

Commit

Permalink
Add build step retries.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenz33 committed Mar 31, 2015
1 parent 06accfd commit eb1f4a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
39 changes: 26 additions & 13 deletions conduct/buildsteps.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class BuildStep(object):
'loglevel' : Parameter(type=oneof(LOGLEVELS.keys()),
description='Log level',
default='info'),
'retries' : Parameter(type=int,
description='Number of retries to execute the '
'build step',
default=0),
}

outparameters = {
Expand Down Expand Up @@ -161,20 +165,29 @@ def build(self):
self.log.info(self.description)
self.log.info('-' * 80)

resultStr = 'SUCCESS'
try:
# execute actual build actions
self.run()
self.wasRun = True
except Exception as exc:
resultStr = 'FAILED'
self.log.exception(exc)
success = False

raise
finally:
self.log.info('')
self.log.info('%s' % resultStr)
self.log.info('=' * 80)
for i in range(0, self.retries +1):
try:
# execute actual build actions
self.run()
self.wasRun = True
success = True
break
except Exception as exc:
self.log.exception(exc)

# handle retries
if self.retries > i:
self.log.warn('Failed; Retry %s/%s' % (i+1, self.retries))

# log some bs stuff
self.log.info('')
self.log.info('%s' % 'SUCCESS' if success else 'FAILED')
self.log.info('=' * 80)

if not success:
raise RuntimeError('Build step failed')

def cleanupBuild(self):
'''
Expand Down
3 changes: 2 additions & 1 deletion etc/chains/frm2/boximg.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
# Build steps
steps.imgdef = Step('conduct.Config',
description='Read image definition file',
path='{chain.imgcfgdir}/{chain.imgname}.py')
path='{chain.imgcfgdir}/{chain.imgname}.py',
retries=1)

steps.tmpdir = Step('conduct.TmpDir',
description='Generate build dir',)
Expand Down

0 comments on commit eb1f4a8

Please sign in to comment.