diff --git a/python_modules/libraries/dagster-k8s/dagster_k8s/ops/k8s_job_op.py b/python_modules/libraries/dagster-k8s/dagster_k8s/ops/k8s_job_op.py index b016a8f2789da..83562d7f7cd76 100644 --- a/python_modules/libraries/dagster-k8s/dagster_k8s/ops/k8s_job_op.py +++ b/python_modules/libraries/dagster-k8s/dagster_k8s/ops/k8s_job_op.py @@ -419,6 +419,20 @@ def execute_k8s_job( num_pods_to_wait_for=num_pods_to_wait_for, ) except (DagsterExecutionInterruptedError, Exception) as e: + try: + pods = api_client.get_pod_names_in_job(job_name=job_name, namespace=namespace) + pod_debug_info = "\n\n".join( + [api_client.get_pod_debug_info(pod_name, namespace) for pod_name in pods] + ) + except Exception: + context.log.exception( + f"Error trying to get pod debug information for failed k8s job {job_name}" + ) + else: + context.log.error( + f"Debug information for failed k8s job {job_name}:\n\n{pod_debug_info}" + ) + if delete_failed_k8s_jobs: context.log.info( f"Deleting Kubernetes job {job_name} in namespace {namespace} due to exception"