diff options
author | Daniel Smith <daniel.smith@qt.io> | 2022-09-07 16:19:48 +0200 |
---|---|---|
committer | Daniel Smith <Daniel.Smith@qt.io> | 2023-04-17 09:34:53 +0000 |
commit | 5031182ac62cf7d0f13b2c56cbd45fc3ca764934 (patch) | |
tree | f6d2f3b5cffc61750b0d357ac411a0bc8f7a9ebb | |
parent | f653ee977a60018ed61f8d584aa72236d0294856 (diff) | |
download | qtrepotools-5031182ac62cf7d0f13b2c56cbd45fc3ca764934.tar.gz |
Make querying internal coin safe and use configurable hostname
It turns out Requests will throw an exception if the hostname
cannot be resolved. Handle this error gracefully and fall back.
Further, if we failed to query coin for some reason,
automatic staging should only be disabled for blocking
modules being updated since automatic staging is a global
behavior of the bot.
Change-Id: I2fbb744576dd5ec946f9738875b0bc4ac0191874
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
-rw-r--r-- | util/dependency_updater/config.yaml.template | 1 | ||||
-rw-r--r-- | util/dependency_updater/tools/config.py | 1 | ||||
-rw-r--r-- | util/dependency_updater/tools/toolbox.py | 12 |
3 files changed, 11 insertions, 3 deletions
diff --git a/util/dependency_updater/config.yaml.template b/util/dependency_updater/config.yaml.template index 81cd9a9..1db7019 100644 --- a/util/dependency_updater/config.yaml.template +++ b/util/dependency_updater/config.yaml.template @@ -2,5 +2,6 @@ GERRIT_HOST: codereview.qt-project.org GERRIT_STATE_PATH: playground/tqtc-personal-projects GERRIT_USERNAME: '' GERRIT_PASSWORD: '' +INTERNAL_COIN_HOST: '' MS_TEAMS_NOTIFY_URL: '' REPOS: [] diff --git a/util/dependency_updater/tools/config.py b/util/dependency_updater/tools/config.py index 7dac495..fe3ea11 100644 --- a/util/dependency_updater/tools/config.py +++ b/util/dependency_updater/tools/config.py @@ -25,6 +25,7 @@ class Config(Namespace): GERRIT_STATE_PATH: str GERRIT_USERNAME: str GERRIT_PASSWORD: str + INTERNAL_COIN_HOST: str MS_TEAMS_NOTIFY_URL: str state_repo: Repo state_data: dict[str, Repo] = {} diff --git a/util/dependency_updater/tools/toolbox.py b/util/dependency_updater/tools/toolbox.py index b168eda..b674eac 100644 --- a/util/dependency_updater/tools/toolbox.py +++ b/util/dependency_updater/tools/toolbox.py @@ -307,7 +307,11 @@ def get_top_integration_sha(config, repo: Repo) -> str: else: # Fallback to internal COIN if available. The task probably hadn't replicated to # testresults yet. - r = requests.get(f"http://coin/coin/api/integration/{repo.id}/tasks/{integration_id}") + try: + r = requests.get(f"http://{config.INTERNAL_COIN_HOST}/coin/api/integration/" + f"{repo.id}/tasks/{integration_id}") + except requests.exceptions.ConnectionError: + pass if r.status_code == 200: sha = json.loads(r.text)[4]["1"]["rec"]["6"]["str"] print(f"Found integration sha {sha} from Integration ID: {integration_id}") @@ -315,8 +319,10 @@ def get_top_integration_sha(config, repo: Repo) -> str: print(f"ERROR: Failed to retrieve integration sha from testresults/coin for integration ID" f" {integration_id}.\n" f"\tRepo: {repo.id}, submodule update change ID: {repo.proposal.change_id}\n" - f"\t{gerrit_link_maker(config, change)}" - f"DISABLING AUTOMATIC STAGING AND CONTINUING...") + f"\t{gerrit_link_maker(config, change)}") + if repo.is_non_blocking: + return "" + print("Disabling automatic stage due to failure to retrieve module integration SHA") config.args.stage = False config.teams_connector.send_teams_webhook_basic( f"Error in updating {repo.id}." |