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

fix timeout reason for k8s #2128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions metaflow/plugins/kubernetes/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ def _has_updates():
raise KubernetesException("%s (exit code %s)" % (msg, exit_code))
else:
msg = "%s (exit code %s)" % (msg, exit_code)
if msg.startswith("DeadlineExceeded"):
raise KubernetesException(msg)
raise KubernetesException(
"%s. This could be a transient error. Use @retry to retry." % msg
)
Expand Down
20 changes: 12 additions & 8 deletions metaflow/plugins/kubernetes/kubernetes_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,22 +732,26 @@ def reason(self):
# If pod status is dirty, check for newer status
self._pod = self._fetch_pod()
if self._pod:
if self._pod.get("status", {}).get("container_statuses") is None:
# We're done, but no container_statuses is set
# This can happen when the pod is evicted
pod_status = self._pod.get("status", {})
pod_reason = pod_status.get("reason")
# Check for pod-level reasons (like timeout) first - whether container_statuses exists or not
# If no container_statuses is set, This can happen when the pod is evicted
if (
pod_reason == "DeadlineExceeded"
or pod_status.get("container_statuses") is None
):
return None, ": ".join(
filter(
None,
[
self._pod.get("status", {}).get("reason"),
self._pod.get("status", {}).get("message"),
pod_status.get("reason"),
pod_status.get("message"),
],
)
)

for k, v in (
self._pod.get("status", {})
.get("container_statuses", [{}])[0]
for _, v in (
pod_status.get("container_statuses", [{}])[0]
.get("state", {})
.items()
):
Expand Down
Loading