Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Dec 15, 2023
1 parent 90188de commit 4ee9df5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions backend/copr_backend/background_worker_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import json
import shlex

from datetime import datetime, timedelta
from datetime import datetime
from packaging import version

from copr_common.enums import StatusEnum
Expand Down Expand Up @@ -783,7 +783,7 @@ def _deploy_user_ssh(self):
"""
pubkey = shlex.quote(self.job.ssh_public_key)
cmd = COMMANDS["echo_authorized_keys"].format(pubkey)
rc, out, err = self.ssh.run_expensive(cmd)
rc, _out, _err = self.ssh.run_expensive(cmd)
if rc != 0:
self.log.error("Failed to deploy user SSH key for %s",
self.job.project_owner)
Expand All @@ -796,7 +796,7 @@ def _set_default_expiration(self):
"""
default = self.job.started_on + USER_SSH_DEFAULT_EXPIRATION
cmd = COMMANDS["set_expiration"].format(shlex.quote(str(default)))
rc, out, err = self.ssh.run_expensive(cmd)
rc, _out, _err = self.ssh.run_expensive(cmd)
if rc != 0:
# This only affects the `copr-builder show` command to print unknown
# remaining time. It won't affect the backend in terminating the
Expand All @@ -809,13 +809,14 @@ def _builder_expiration(self):
"""
Find the user preference for the builder expiration.
"""
rc, out, err = self.ssh.run_expensive(COMMANDS["cat_expiration"])
rc, out, _err = self.ssh.run_expensive(COMMANDS["cat_expiration"])
if rc == 0:
try:
return datetime.fromtimestamp(float(out))
except ValueError:
pass
self.log.error("Unable to query builder expiration file")
return None

def _keep_alive_for_user_ssh(self):
"""
Expand Down Expand Up @@ -845,12 +846,14 @@ def _keep_alive():
break
time.sleep(60)

transfer_failure = CancellableThreadTask(
CancellableThreadTask(
_keep_alive,
self._cancel_task_check_request,
self._cancel_running_worker,
check_period=CANCEL_CHECK_PERIOD,
).run()
if self.canceled:
raise BuildCanceled

def build(self, attempt):
"""
Expand Down
2 changes: 2 additions & 0 deletions backend/copr_backend/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self, task_data, worker_opts):
- timeout: default worker timeout
"""
# pylint: disable=too-many-statements

self.timeout = worker_opts.timeout
self.frontend_base_url = worker_opts.frontend_base_url
Expand Down Expand Up @@ -73,6 +74,7 @@ def __init__(self, task_data, worker_opts):
self.results = None
self.appstream = None
self.allow_user_ssh = None
self.ssh_public_key = None

# TODO: validate update data
for key, val in task_data.items():
Expand Down

0 comments on commit 4ee9df5

Please sign in to comment.