Skip to content

Commit

Permalink
backend: longer timeout for fallback generating GPG keys after build
Browse files Browse the repository at this point in the history
Fix fedora-copr#2911
Fix fedora-copr#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.

To trigger this fallback, you can do:

    docker-compose stop keygen-httpd
    copr create test-srpm-key --chroot fedora-38-x86_64
    copr buildscm --clone-url ... test-srpm-key
    # Wait few minutes until the action fails
    docker-compose start keygen-httpd
  • Loading branch information
FrostyX committed Oct 14, 2023
1 parent c381e34 commit 8fd0283
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/copr_backend/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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(
Expand Down

0 comments on commit 8fd0283

Please sign in to comment.