Skip to content

Commit 2023a76

Browse files
authored
Remove before_log in KPO retry and add traceback when interrupted (#35423)
2 small logging "fixes" 1. usually tenacity retry will not be invoked. No need to add confusing log messages when there's not actually a retry. 2. When log read is interrupted and pod still running, something exceptional has happened. Let's just include the traceback rather than forcing user to enable debug logging.
1 parent 6858ea4 commit 2023a76

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

airflow/providers/cncf/kubernetes/utils/pod_manager.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import enum
2121
import itertools
2222
import json
23-
import logging
2423
import math
2524
import time
2625
import warnings
@@ -37,7 +36,6 @@
3736
from kubernetes.stream import stream as kubernetes_stream
3837
from pendulum import DateTime
3938
from pendulum.parsing.exceptions import ParserError
40-
from tenacity import before_log
4139
from typing_extensions import Literal
4240
from urllib3.exceptions import HTTPError as BaseHTTPError
4341

@@ -392,7 +390,6 @@ def fetch_container_logs(
392390
retry=tenacity.retry_if_exception_type(ApiException),
393391
stop=tenacity.stop_after_attempt(10),
394392
wait=tenacity.wait_fixed(1),
395-
before=before_log(self.log, logging.INFO),
396393
)
397394
def consume_logs(
398395
*,
@@ -452,17 +449,10 @@ def consume_logs(
452449
self._progress_callback(line)
453450
self.log.info("[%s] %s", container_name, message_to_log)
454451
last_captured_timestamp = message_timestamp
455-
except BaseHTTPError as e:
456-
self.log.warning(
457-
"Reading of logs interrupted for container %r with error %r; will retry. "
458-
"Set log level to DEBUG for traceback.",
452+
except BaseHTTPError:
453+
self.log.exception(
454+
"Reading of logs interrupted for container %r; will retry.",
459455
container_name,
460-
e,
461-
)
462-
self.log.debug(
463-
"Traceback for interrupted logs read for pod %r",
464-
pod.metadata.name,
465-
exc_info=True,
466456
)
467457
return last_captured_timestamp or since_time, logs
468458

0 commit comments

Comments
 (0)