Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HWORKS-985] Handle transient errors in Execution.download_logs() with retry #191

Merged
merged 8 commits into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions python/hopsworks/engine/execution_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import time
import uuid

from hopsworks.client.exceptions import JobExecutionException
from hopsworks.client.exceptions import JobExecutionException, RestAPIError


class ExecutionEngine:
Expand Down Expand Up @@ -56,20 +56,38 @@ def download_logs(self, execution, path=None):
if execution.stdout_path is not None and self._dataset_api.exists(
execution.stdout_path
):
out_path = self._dataset_api.download(
execution.stdout_path, download_log_dir
)
out_path = self._download_log(execution.stdout_path, download_log_dir)

err_path = None
if execution.stderr_path is not None and self._dataset_api.exists(
execution.stderr_path
):
err_path = self._dataset_api.download(
execution.stderr_path, download_log_dir
)
err_path = self._download_log(execution.stderr_path, download_log_dir)

return out_path, err_path

def _download_log(self, path, download_log_dir):
max_num_retries = 12
retries = 0
download_path = None
while retries < max_num_retries:
try:
download_path = self._dataset_api.download(
path, download_log_dir, overwrite=True
)
break
except RestAPIError as e:
if (
e.response.json().get("errorCode", "") == 110021
and e.response.status_code == 400
and retries < max_num_retries
):
retries += 1
time.sleep(5)
else:
raise e
return download_path

def wait_until_finished(self, job, execution):
"""Wait until execution reaches terminal state
:param execution: job of the execution
Expand Down
Loading