Record job build attempts in inventory

Record the number of attempts zuul has made to run this job in the job
inventory. This will help expose reliability information in job logs and
in job log indexers. We want to try and expose job reliability as much
as possible and this is one way to do that.

Change-Id: I2f7c31ce510f59bc569c5db89ce6626d9e3ef436
changes/48/697548/3
Clark Boylan 3 years ago
parent 938ca7b8b4
commit 9f18243dab

@ -313,6 +313,13 @@ of item.
A boolean indicating whether the job is voting.
.. var:: attempts
An integer count of how many attempts have been made to run this
job for the current buildset. If there are pre-run failures or network
connectivity issues then previous attempts may have been cancelled,
and this value will be greater than 1.
.. var:: project
The item's project. This is a data structure with the following

@ -143,6 +143,8 @@ class TestInventory(TestInventoryBase):
self.assertEqual(
'/usr/bin/python2', node_vars['ansible_python_interpreter'])
self.assertIn('zuul', inventory['all']['vars'])
self.assertIn('attempts', inventory['all']['vars']['zuul'])
self.assertEqual(1, inventory['all']['vars']['zuul']['attempts'])
z_vars = inventory['all']['vars']['zuul']
self.assertIn('executor', z_vars)
self.assertIn('src_root', z_vars['executor'])

@ -318,6 +318,11 @@ class ExecutorClient(object):
self.sched.onBuildCompleted(build, 'SUCCESS', {}, [])
return build
# Update zuul attempts after addBuild above to ensure build_set
# is up to date.
attempts = build.build_set.getTries(job.name)
zuul_params['attempts'] = attempts
functions = getGearmanFunctions(self.gearman)
function_name = 'executor:execute'
# Because all nodes belong to the same provider, region and

Loading…
Cancel
Save