Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Exception when parsing log #20966 #21053

Closed
wants to merge 11 commits into from
2 changes: 1 addition & 1 deletion airflow/hooks/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def pre_exec():
raise RuntimeError("The subprocess should be created here and is None!")
if self.sub_process.stdout is not None:
for raw_line in iter(self.sub_process.stdout.readline, b''):
line = raw_line.decode(output_encoding).rstrip()
line = raw_line.decode(output_encoding, errors='backslashreplace').rstrip()
self.log.info("%s", line)

self.sub_process.wait()
Expand Down
3 changes: 2 additions & 1 deletion airflow/providers/cncf/kubernetes/utils/pod_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def follow_logs(since_time: Optional[DateTime] = None) -> Optional[DateTime]:
),
)
for line in logs:
timestamp, message = self.parse_log_line(line.decode('utf-8'))
line = line.decode('utf-8', errors="backslashreplace")
timestamp, message = self.parse_log_line(line)
self.log.info(message)
Comment on lines 201 to 204
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                for raw_line in logs:
                    line = raw_line.decode('utf-8', errors="backslashreplace")
                    timestamp, message = self.parse_log_line(line)

except BaseHTTPError: # Catches errors like ProtocolError(TimeoutError).
self.log.warning(
Expand Down