drsantos20 commented on a change in pull request #7428: [AIRFLOW-4526] Poll k8s
logs to avoid problem with kubernetes logs --follow
URL: https://github.com/apache/airflow/pull/7428#discussion_r379871369
##########
File path: airflow/kubernetes/pod_launcher.py
##########
@@ -219,22 +218,33 @@ def read_pod_logs(self, pod: Pod) -> Generator[str,
None, None]:
while pod_is_running:
pod_is_running = self.pod_is_running(pod)
- resp = self._read_pod_log_chunk(pod, last_chunk_timestamp)
+ # The CoreV1Api doesn't support since_time even though the API
does, so we must use
+ # since_seconds. Add 15 seconds of buffer just in case of NTP
woes
+ if last_chunk_timestamp:
+ # Strip fractional part because strptime doesn't support
nanosecond parsing
+ last_chunk_dt =
dt.strptime(last_chunk_timestamp.split(b".", 1)[0].decode("utf-8"),
+ "%Y-%m-%dT%H:%M:%S")
+ since_seconds = math.ceil((dt.utcnow() -
last_chunk_dt).total_seconds() + 15)
+ else:
+ since_seconds = math.ceil(dt.utcnow().timestamp())
+ resp = self._read_pod_log_chunk(pod, since_seconds)
# Just in case the assumption that never duplicating across
# lines is wrong, we store the previous line's timestamp and
# log a warning just in case
last_line_timestamp = None
for line in resp:
- timestamp, line = line.split(' ', 1)
+ timestamp, line = line.split(b" ", 1)
Review comment:
hi @sarah-johnson There are any differences between a simple quotes and
double quotes?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services