Skip to content

Commit

Permalink
src/tarball: update checkout node when update repo fails
Browse files Browse the repository at this point in the history
Tarball updates source code repo and creates tarball.
If update repo operation fails even with second attempt,
it means it failed to checkout souce code.
Hence, update `checkout` node with state `done` state and
result `fail`. Also, set appropriate error information
to the `data` field.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia authored and nuclearcat committed Apr 19, 2024
1 parent 7b43687 commit 5cf9bef
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,22 @@ def _update_node(self, checkout_node, describe, version, tarball_url):
err_msg = json.loads(err.response.content).get("detail", [])
self.log.error(err_msg)

def _update_failed_checkout_node(self, checkout_node, error_code, error_msg):
node = checkout_node.copy()
node.update({
'state': 'done',
'result': 'fail',
})
if 'data' not in node:
node['data'] = {}
node['data']['error_code'] = error_code
node['data']['error_msg'] = error_msg
try:
self._api.node.update(node)
except requests.exceptions.HTTPError as err:
err_msg = json.loads(err.response.content).get("detail", [])
self.log.error(err_msg)

def _setup(self, args):
return self._api_helper.subscribe_filters({
'op': 'created',
Expand Down Expand Up @@ -163,6 +179,10 @@ def _run(self, sub_id):
if self._update_repo(build_config):
# critical failure, something wrong with git
self.log.error("Failed to update repo again, exit")
# Set checkout node result to fail
self._update_failed_checkout_node(checkout_node,
'git_checkout_failure',
'Failed to init/update git repo')
os._exit(1)

describe = kernelci.build.git_describe(
Expand Down

0 comments on commit 5cf9bef

Please sign in to comment.