akki commented on a change in pull request #6552: AIRFLOW-5850: Capture task
logs in DockerSwarmOperator
URL: https://github.com/apache/airflow/pull/6552#discussion_r358641668
##########
File path: airflow/contrib/operators/docker_swarm_operator.py
##########
@@ -123,11 +129,43 @@ def _run_image(self):
self.log.info('Service started: %s', str(self.service))
- status = None
# wait for the service to start the task
while not self.cli.tasks(filters={'service': self.service['ID']}):
continue
- while True:
+
+ logs = self.cli.service_logs(
+ self.service['ID'], follow=True, stdout=True, stderr=True,
is_tty=self.tty
+ )
+ line = ''
+ _stream_logs = self.enable_logging # Status of the service_logs'
generator
+ while True: # pylint: disable=too-many-nested-blocks
+ if self.enable_logging:
Review comment:
I had tried that earlier but this whole block makes sense only if put
together. The `while True` has 2 responsibilities - log things and check if the
service still running - but I don't see any straightforward way to decouple
them.
Also, this block waits for the service to stop which doesn't make sens
without the part where the service is started.
Do you have any particular ideas in mind?
----------------------------------------------------------------
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