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 b4b84a1  Add kernel capabilities in DockerOperator(#9142)
b4b84a1 is described below

commit b4b84a1933d055a2803b80b990482a7257a203ff
Author: Damjan Postolovski <[email protected]>
AuthorDate: Sun Jun 7 15:11:45 2020 +0200

    Add kernel capabilities in DockerOperator(#9142)
---
 airflow/providers/docker/operators/docker.py    | 7 ++++++-
 tests/providers/docker/operators/test_docker.py | 3 ++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/airflow/providers/docker/operators/docker.py 
b/airflow/providers/docker/operators/docker.py
index 655ced9..39a068c 100644
--- a/airflow/providers/docker/operators/docker.py
+++ b/airflow/providers/docker/operators/docker.py
@@ -123,6 +123,8 @@ class DockerOperator(BaseOperator):
     :param tty: Allocate pseudo-TTY to the container
         This needs to be set see logs of the Docker container.
     :type tty: bool
+    :param cap_add: Include container capabilities
+    :type cap_add: list[str]
     """
     template_fields = ('command', 'environment', 'container_name')
     template_ext = ('.sh', '.bash',)
@@ -159,6 +161,7 @@ class DockerOperator(BaseOperator):
             auto_remove: bool = False,
             shm_size: Optional[int] = None,
             tty: Optional[bool] = False,
+            cap_add: Optional[Iterable[str]] = None,
             *args,
             **kwargs) -> None:
 
@@ -191,6 +194,7 @@ class DockerOperator(BaseOperator):
         self.docker_conn_id = docker_conn_id
         self.shm_size = shm_size
         self.tty = tty
+        self.cap_add = cap_add
         if kwargs.get('xcom_push') is not None:
             raise AirflowException("'xcom_push' was deprecated, use 
'BaseOperator.do_xcom_push' instead")
 
@@ -231,7 +235,8 @@ class DockerOperator(BaseOperator):
                     dns=self.dns,
                     dns_search=self.dns_search,
                     cpu_shares=int(round(self.cpus * 1024)),
-                    mem_limit=self.mem_limit),
+                    mem_limit=self.mem_limit,
+                    cap_add=self.cap_add),
                 image=self.image,
                 user=self.user,
                 working_dir=self.working_dir,
diff --git a/tests/providers/docker/operators/test_docker.py 
b/tests/providers/docker/operators/test_docker.py
index 7e1dbdf..0702888 100644
--- a/tests/providers/docker/operators/test_docker.py
+++ b/tests/providers/docker/operators/test_docker.py
@@ -82,7 +82,8 @@ class TestDockerOperator(unittest.TestCase):
                                                                mem_limit=None,
                                                                
auto_remove=False,
                                                                dns=None,
-                                                               dns_search=None)
+                                                               dns_search=None,
+                                                               cap_add=None)
         tempdir_mock.assert_called_once_with(dir='/host/airflow', 
prefix='airflowtmp')
         client_mock.images.assert_called_once_with(name='ubuntu:latest')
         client_mock.attach.assert_called_once_with(container='some_id', 
stdout=True,

Reply via email to