From 140489dcccb7be5be40cc8f5a63e352ae17963a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Aquilina?= <32460579+dreaquil@users.noreply.github.com> Date: Fri, 4 Jun 2021 14:37:11 +0100 Subject: [PATCH] Fix cli create git fail (#3267) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix issue of infinite loop due to incorrect status comparison. * Update CHANGELOG.md * Fix PEP8. * Update failure case to break from infinite loop. * Update utils/cli/core/core.py Co-authored-by: Boris Sekachev * Add check for unknown failure. * Fix logging in failure case. * Update CHANGELOG.md Co-authored-by: Boris Sekachev Co-authored-by: André Aquilina --- CHANGELOG.md | 1 + utils/cli/core/core.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f6647a5756..995f0e2e893d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Project page requests took a long time and did many DB queries () - Fixed Python 3.6 support () - Incorrect attribute import in tracks () +- Fix CLI create an infinite loop if git repository responds with failure () ### Security diff --git a/utils/cli/core/core.py b/utils/cli/core/core.py index 5f126a043745..31c12e2736c9 100644 --- a/utils/cli/core/core.py +++ b/utils/cli/core/core.py @@ -124,14 +124,16 @@ def tasks_create(self, name, labels, overlap, segment_size, bug, resource_type, check_url = self.api.git_check(rq_id) response = self.session.get(check_url) response_json = response.json() - log.info('''Awaiting dataset repository for task. Status: {}'''.format( - response_json['status'])) while response_json['status'] != 'finished': + log.info('''Awaiting a dataset repository to be created for the task. Response status: {}'''.format( + response_json['status'])) sleep(git_completion_verification_period) response = self.session.get(check_url) response_json = response.json() - if response_json['status'] == 'Failed': - log.error(f'Dataset repository creation request for task {task_id} failed.') + if response_json['status'] == 'failed' or response_json['status'] == 'unknown': + log.error(f'Dataset repository creation request for task {task_id} failed' + f'with status {response_json["status"]}.') + break log.info(f"Dataset repository creation completed with status: {response_json['status']}.")