Skip to content

Commit 779b75a

Browse files
authored
Fix bugs (#106)
Issues caused by updated dependencies: - Catch requests retry error from `run.jobs()` Issues with #100: - Remove unsupported `level` from `action.note()` call Old minor issue: - Add context to server recycling error
1 parent d95ffe8 commit 779b75a

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

testflows/github/hetzner/runners/scale_up.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
from github.SelfHostedActionsRunner import SelfHostedActionsRunner
5858
from github.GithubException import GithubException
5959

60+
from requests.exceptions import RetryError as RequestsRetryError
61+
6062
from concurrent.futures import ThreadPoolExecutor, Future
6163

6264
# Lock to access the volumes list
@@ -556,11 +558,10 @@ def filtered_run_jobs(
556558
for run in workflow_runs:
557559
try:
558560
jobs = list(run.jobs())
559-
except GithubException as exc:
560-
# Log and skip API calls that fail (e.g., GitHub 502)
561+
except (GithubException, RequestsRetryError) as exc:
562+
# Log and skip API calls that fail (e.g., GitHub 502, timeout, retry errors)
561563
action.note(
562-
f"WARNING:Skipping workflow run {run.id}, failed to fetch jobs: {exc}",
563-
level=logging.WARNING,
564+
f"WARNING:Skipping workflow run {run.id}, failed to fetch jobs: {exc}"
564565
)
565566
continue
566567

@@ -893,9 +894,17 @@ def recycle_server(
893894
server.labels = server_labels
894895

895896
with Action(f"Rebuilding recycled server {server.name} image", server_name=name):
896-
server.rebuild(image=server_image).action.wait_until_finished(
897-
max_retries=timeout
898-
)
897+
try:
898+
server.rebuild(image=server_image).action.wait_until_finished(
899+
max_retries=timeout
900+
)
901+
except APIException as exc:
902+
# Re-raise with context since Hetzner's server_error has message=None
903+
raise APIException(
904+
code=exc.code,
905+
message=f"error while rebuilding recycled server {server.name}: {exc.message}",
906+
details=getattr(exc, "details", None),
907+
) from exc
899908

900909
setup_worker_pool.submit(
901910
server_setup,

0 commit comments

Comments
 (0)