Skip to content

Commit

Permalink
[Logs] Fix /build/status returning 500 when failing kubectl logs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
quaark committed May 30, 2023
1 parent 8eed891 commit aad5b69
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mlrun/api/api/endpoints/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Response,
)
from fastapi.concurrency import run_in_threadpool
from kubernetes.client.rest import ApiException
from sqlalchemy.orm import Session

import mlrun.api.crud
Expand Down Expand Up @@ -488,7 +489,18 @@ def _handle_job_deploy_status(
state = mlrun.common.schemas.FunctionState.error

if (logs and state != "pending") or state in terminal_states:
resp = mlrun.api.utils.singletons.k8s.get_k8s_helper(silent=False).logs(pod)
try:
resp = mlrun.api.utils.singletons.k8s.get_k8s_helper(silent=False).logs(pod)
except ApiException as exc:
logger.warning(
"Failed to get build logs",
function_name=name,
function_state=state,
pod=pod,
exc_info=exc,
)
resp = ""

if state in terminal_states:
# TODO: move to log collector
log_file.parent.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit aad5b69

Please sign in to comment.