Skip to content

Commit

Permalink
Fix Fargate logging for AWS system tests (#31622)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: ferruzzi <ferruzzi@amazon.com>
  • Loading branch information
vincbeck and ferruzzi committed Jun 4, 2023
1 parent 495ae23 commit def4b53
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions airflow/providers/cncf/kubernetes/utils/pod_manager.py
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import json
import logging
import math
import time
import warnings
Expand All @@ -35,6 +36,7 @@
from kubernetes.stream import stream as kubernetes_stream
from pendulum import DateTime
from pendulum.parsing.exceptions import ParserError
from tenacity import before_log
from urllib3.exceptions import HTTPError as BaseHTTPError
from urllib3.response import HTTPResponse

Expand Down Expand Up @@ -337,9 +339,20 @@ def fetch_container_logs(
) -> PodLoggingStatus:
"""
Follows the logs of container and streams to airflow logging.
Returns when container exits.
Between when the pod starts and logs being available, there might be a delay due to CSR not approved
and signed yet. In such situation, ApiException is thrown. This is why we are retrying on this
specific exception.
"""

@tenacity.retry(
retry=tenacity.retry_if_exception_type(ApiException),
stop=tenacity.stop_after_attempt(10),
wait=tenacity.wait_fixed(1),
before=before_log(self.log, logging.INFO),
)
def consume_logs(
*, since_time: DateTime | None = None, follow: bool = True, termination_timeout: int = 120
) -> DateTime | None:
Expand Down

0 comments on commit def4b53

Please sign in to comment.