From 00bbb301148ade281da9ecdc3f54622963557b89 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Sat, 14 Oct 2023 13:19:55 +0200 Subject: [PATCH] backend: longer timeout for fallback generating GPG keys after build Fix #2911 Fix #2942 When frontend is creating a new project, it creates an action to generate GPG keys. This may fail because of a temporary keygen downtime or network issues. Once a SRPM is built, we try to use the GPG key and it doesn't exist, there is a fallback, trying to generate the key again. We can try longer. --- backend/copr_backend/sign.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/copr_backend/sign.py b/backend/copr_backend/sign.py index 6655fb98a..9c65ef3f5 100644 --- a/backend/copr_backend/sign.py +++ b/backend/copr_backend/sign.py @@ -167,7 +167,11 @@ def sign_rpms_in_dir(username, projectname, path, chroot, opts, log): try: get_pubkey(username, projectname, log, opts.sign_domain) except CoprSignNoKeyError: - create_user_keys(username, projectname, opts) + # We don't want to try in indefinitely because that could lead to + # forver stuck builds but we can afford trying to create the key for + # several hours + timeout = 60 * 60 * 10 + create_user_keys(username, projectname, opts, timeout=timeout) errors = [] # tuples (rpm_filepath, exception) for rpm in rpm_list: @@ -185,7 +189,7 @@ def sign_rpms_in_dir(username, projectname, path, chroot, opts, log): .format([err[0] for err in errors])) -def create_user_keys(username, projectname, opts): +def create_user_keys(username, projectname, opts, timeout=None): """ Generate a new key-pair at sign host @@ -204,7 +208,8 @@ def create_user_keys(username, projectname, opts): keygen_url = "http://{}/gen_key".format(opts.keygen_host) query = dict(url=keygen_url, data=data, method="post") try: - request = SafeRequest(log=log) + timeout = timeout or 2 * 60 + request = SafeRequest(log=log, timeout=timeout) response = request.send(**query) except Exception as e: raise CoprKeygenRequestError(