You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/07/18 13:15:37 UTC
[airflow] branch main updated: [FIX] Docker provider - retry docker
in docker (#17061)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new b076ac5 [FIX] Docker provider - retry docker in docker (#17061)
b076ac5 is described below
commit b076ac5925e1a316dd6e9ad8ee4d1a2223e376ca
Author: raphaelauv <ra...@users.noreply.github.com>
AuthorDate: Sun Jul 18 15:15:10 2021 +0200
[FIX] Docker provider - retry docker in docker (#17061)
---
airflow/providers/docker/operators/docker.py | 6 +++---
tests/providers/docker/operators/test_docker.py | 7 +++++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/airflow/providers/docker/operators/docker.py b/airflow/providers/docker/operators/docker.py
index e167113..5387e48 100644
--- a/airflow/providers/docker/operators/docker.py
+++ b/airflow/providers/docker/operators/docker.py
@@ -247,12 +247,12 @@ class DockerOperator(BaseOperator):
if not self.cli:
raise Exception("The 'cli' should be initialized before!")
if self.mount_tmp_dir:
- with TemporaryDirectory(prefix='airflowtmp', dir=self.host_tmp_dir) as host_tmp_dir:
- tmp_mount = Mount(self.tmp_dir, host_tmp_dir, "bind")
+ with TemporaryDirectory(prefix='airflowtmp', dir=self.host_tmp_dir) as host_tmp_dir_generated:
+ tmp_mount = Mount(self.tmp_dir, host_tmp_dir_generated, "bind")
try:
return self._run_image_with_mounts(self.mounts + [tmp_mount], add_tmp_variable=True)
except APIError as e:
- if self.host_tmp_dir in str(e):
+ if host_tmp_dir_generated in str(e):
self.log.warning(
"Using remote engine or docker-in-docker and mounting temporary "
"volume from host is not supported. Falling back to "
diff --git a/tests/providers/docker/operators/test_docker.py b/tests/providers/docker/operators/test_docker.py
index bb4c107..78bb968 100644
--- a/tests/providers/docker/operators/test_docker.py
+++ b/tests/providers/docker/operators/test_docker.py
@@ -35,11 +35,14 @@ except ImportError:
pass
+TEMPDIR_MOCK_RETURN_VALUE = '/mkdtemp'
+
+
class TestDockerOperator(unittest.TestCase):
def setUp(self):
self.tempdir_patcher = mock.patch('airflow.providers.docker.operators.docker.TemporaryDirectory')
self.tempdir_mock = self.tempdir_patcher.start()
- self.tempdir_mock.return_value.__enter__.return_value = '/mkdtemp'
+ self.tempdir_mock.return_value.__enter__.return_value = TEMPDIR_MOCK_RETURN_VALUE
self.client_mock = mock.Mock(spec=APIClient)
self.client_mock.create_container.return_value = {'Id': 'some_id'}
@@ -185,7 +188,7 @@ class TestDockerOperator(unittest.TestCase):
def test_execute_fallback_temp_dir(self):
self.client_mock.create_container.side_effect = [
- APIError(message="wrong path: " + "/host/airflow"),
+ APIError(message="wrong path: " + TEMPDIR_MOCK_RETURN_VALUE),
{'Id': 'some_id'},
]
operator = DockerOperator(