From 5cd17c9268aa56ac6438035a0a1b8e933d90762c Mon Sep 17 00:00:00 2001 From: Dagang Wei Date: Fri, 17 Nov 2023 16:46:50 -0800 Subject: [PATCH] KubernetesPodTrigger: add stacktrace to event message Ref #34644 --- airflow/providers/cncf/kubernetes/operators/pod.py | 1 + airflow/providers/cncf/kubernetes/triggers/pod.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/airflow/providers/cncf/kubernetes/operators/pod.py b/airflow/providers/cncf/kubernetes/operators/pod.py index 3cacb126d07d2..8ad803608a17c 100644 --- a/airflow/providers/cncf/kubernetes/operators/pod.py +++ b/airflow/providers/cncf/kubernetes/operators/pod.py @@ -672,6 +672,7 @@ def invoke_defer_method(self): ) def execute_complete(self, context: Context, event: dict, **kwargs): + self.log.info("Triggered with event: %s", event) pod = None try: pod = self.hook.get_pod( diff --git a/airflow/providers/cncf/kubernetes/triggers/pod.py b/airflow/providers/cncf/kubernetes/triggers/pod.py index 5eda4242769a0..99481ccf2e56d 100644 --- a/airflow/providers/cncf/kubernetes/triggers/pod.py +++ b/airflow/providers/cncf/kubernetes/triggers/pod.py @@ -18,6 +18,7 @@ import asyncio import datetime +import traceback import warnings from asyncio import CancelledError from enum import Enum @@ -225,12 +226,13 @@ async def run(self) -> AsyncIterator[TriggerEvent]: # type: ignore[override] ) except Exception as e: self.log.exception("Exception occurred while checking pod phase:") + stack_trace = traceback.format_exc() yield TriggerEvent( { "name": self.pod_name, "namespace": self.pod_namespace, "status": "error", - "message": str(e), + "message": f"{str(e)}\n{stack_trace}", } )