uranusjr commented on a change in pull request #21175:
URL: https://github.com/apache/airflow/pull/21175#discussion_r795419744
##########
File path: airflow/providers/docker/operators/docker.py
##########
@@ -275,32 +275,40 @@ def _run_image_with_mounts(self, target_mounts,
add_tmp_variable: bool) -> Optio
working_dir=self.working_dir,
tty=self.tty,
)
- lines = self.cli.attach(container=self.container['Id'], stdout=True,
stderr=True, stream=True)
+ logstream = self.cli.attach(container=self.container['Id'],
stdout=True, stderr=True, stream=True)
try:
self.cli.start(self.container['Id'])
- line = ''
- res_lines = []
- return_value = None
- for line in lines:
- if hasattr(line, 'decode'):
+ log_lines = []
+ for log_chunk in logstream:
+ if hasattr(log_chunk, 'decode'):
# Note that lines returned can also be byte sequences so
we have to handle decode here
- line = line.decode('utf-8')
- line = line.strip()
- res_lines.append(line)
- self.log.info(line)
+ log_chunk = log_chunk.decode('utf-8')
+ log_chunk = log_chunk.strip()
+ log_lines.append(log_chunk)
+ self.log.info("%s", log_chunk)
+
result = self.cli.wait(self.container['Id'])
if result['StatusCode'] != 0:
- res_lines = "\n".join(res_lines)
- raise AirflowException('docker container failed: ' +
repr(result) + f"lines {res_lines}")
- if self.retrieve_output and not return_value:
- return_value = self._attempt_to_retrieve_result()
- ret = None
+ log_lines = "\n".join(log_lines)
+ raise AirflowException(f'Docker container failed:
{repr(result)} lines {log_lines}')
Review comment:
```suggestion
joined_log_lines = "\n".join(log_lines)
raise AirflowException(f'Docker container failed:
{repr(result)} lines {joined_log_lines}')
```
to satisfy Mypy.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]