This is an automated email from the ASF dual-hosted git repository.
kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 4a74cf1 Fix xcom in DockerOperator when auto_remove is used (#9173)
4a74cf1 is described below
commit 4a74cf1a34cf20e49383f27e7cdc3ae80b9b0cde
Author: Eric Lopes <[email protected]>
AuthorDate: Mon Jun 8 13:30:12 2020 +0800
Fix xcom in DockerOperator when auto_remove is used (#9173)
---
airflow/providers/docker/operators/docker.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/airflow/providers/docker/operators/docker.py
b/airflow/providers/docker/operators/docker.py
index 39a068c..bbdf3da 100644
--- a/airflow/providers/docker/operators/docker.py
+++ b/airflow/providers/docker/operators/docker.py
@@ -228,7 +228,7 @@ class DockerOperator(BaseOperator):
name=self.container_name,
environment={**self.environment, **self._private_environment},
host_config=self.cli.create_host_config(
- auto_remove=self.auto_remove,
+ auto_remove=False,
binds=self.volumes,
network_mode=self.network_mode,
shm_size=self.shm_size,
@@ -262,11 +262,15 @@ class DockerOperator(BaseOperator):
raise AirflowException('docker container failed: ' +
repr(result))
# duplicated conditional logic because of expensive operation
+ ret = None
if self.do_xcom_push:
- return self.cli.logs(container=self.container['Id']) \
+ ret = self.cli.logs(container=self.container['Id']) \
if self.xcom_all else line.encode('utf-8')
- else:
- return None
+
+ if self.auto_remove:
+ self.cli.remove_container(self.container['Id'])
+
+ return ret
def execute(self, context):
self.cli = self._get_cli()