You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/09 21:47:41 UTC

[GitHub] [airflow] CaptainCuddleCube opened a new pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

CaptainCuddleCube opened a new pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671
 
 
   The docker operator currently does not have a means to pass in an environment dict that is not exposed to the frontend.
   
   This links to issue 6574. 
   
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [ ] Description above provides context of the change
   - [ ] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = JIRA ID<sup>*</sup>
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [ ] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [ ] Relevant documentation is updated including usage instructions.
   - [ ] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   <sup>*</sup> For document-only changes commit message can start with `[AIRFLOW-XXXX]`.
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] CaptainCuddleCube commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
CaptainCuddleCube commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#issuecomment-599233637
 
 
   @feluelle 
   Just following up on the state of this PR. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390268570
 
 

 ##########
 File path: airflow/providers/docker/operators/docker.py
 ##########
 @@ -218,7 +224,7 @@ def _run_image(self):
             self.container = self.cli.create_container(
                 command=self.get_command(),
                 name=self.container_name,
-                environment=self.environment,
+                environment={**self.environment, **self._private_environment},
 
 Review comment:
   ```suggestion
                   environment={**self.environment, **self.private_environment},
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] CaptainCuddleCube commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
CaptainCuddleCube commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#issuecomment-597517998
 
 
   @feluelle 
   
   Updated, and ready for review again. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390275561
 
 

 ##########
 File path: airflow/providers/docker/operators/docker.py
 ##########
 @@ -169,6 +173,7 @@ def __init__(
         self.dns_search = dns_search
         self.docker_url = docker_url
         self.environment = environment or {}
+        self._private_environment = private_environment or {}
 
 Review comment:
   Ah I understand.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390270784
 
 

 ##########
 File path: tests/providers/docker/operators/test_docker.py
 ##########
 @@ -81,13 +83,25 @@ def test_execute(self, client_class_mock, tempdir_mock):
                                                                auto_remove=False,
                                                                dns=None,
                                                                dns_search=None)
-        tempdir_mock.assert_called_once_with(dir='/host/airflow', prefix='airflowtmp')
+        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,
                                                    stderr=True, stream=True)
         client_mock.pull.assert_called_once_with('ubuntu:latest', stream=True)
         client_mock.wait.assert_called_once_with('some_id')
 
+    def test_private_environment_is_private(self):
+        operator = DockerOperator(api_version='1.19', command='env', environment={'UNIT': 'TEST'},
+                                  private_environment={'PRIVATE': 'MESSAGE'}, image='ubuntu:latest',
+                                  network_mode='bridge', owner='unittest', task_id='unittest',
+                                  volumes=['/host/path:/container/path'],
+                                  working_dir='/container/path', shm_size=1000,
+                                  host_tmp_dir='/host/airflow', container_name='test_container',
+                                  tty=True)
+        self.assertEqual(getattr(operator, '_private_environment'), {
+                         'PRIVATE': 'MESSAGE'})
 
 Review comment:
   ```suggestion
           assert operator.private_environment == {'PRIVATE': 'MESSAGE'}
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk merged pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] boring-cyborg[bot] commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#issuecomment-605923042
 
 
   Awesome work, congrats on your first merged pull request!
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390272047
 
 

 ##########
 File path: tests/providers/docker/operators/test_docker.py
 ##########
 @@ -81,13 +83,25 @@ def test_execute(self, client_class_mock, tempdir_mock):
                                                                auto_remove=False,
                                                                dns=None,
                                                                dns_search=None)
-        tempdir_mock.assert_called_once_with(dir='/host/airflow', prefix='airflowtmp')
+        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,
                                                    stderr=True, stream=True)
         client_mock.pull.assert_called_once_with('ubuntu:latest', stream=True)
         client_mock.wait.assert_called_once_with('some_id')
 
+    def test_private_environment_is_private(self):
+        operator = DockerOperator(api_version='1.19', command='env', environment={'UNIT': 'TEST'},
+                                  private_environment={'PRIVATE': 'MESSAGE'}, image='ubuntu:latest',
+                                  network_mode='bridge', owner='unittest', task_id='unittest',
+                                  volumes=['/host/path:/container/path'],
+                                  working_dir='/container/path', shm_size=1000,
+                                  host_tmp_dir='/host/airflow', container_name='test_container',
+                                  tty=True)
 
 Review comment:
   ```suggestion
           operator = DockerOperator(private_environment={'PRIVATE': 'MESSAGE'}, image='ubuntu:latest')
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] CaptainCuddleCube commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
CaptainCuddleCube commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390274469
 
 

 ##########
 File path: airflow/providers/docker/operators/docker.py
 ##########
 @@ -169,6 +173,7 @@ def __init__(
         self.dns_search = dns_search
         self.docker_url = docker_url
         self.environment = environment or {}
+        self._private_environment = private_environment or {}
 
 Review comment:
   @feluelle  I make this an underscore attribute so that it doesn't get rendered on the frontend at all. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390268452
 
 

 ##########
 File path: airflow/providers/docker/operators/docker.py
 ##########
 @@ -169,6 +173,7 @@ def __init__(
         self.dns_search = dns_search
         self.docker_url = docker_url
         self.environment = environment or {}
+        self._private_environment = private_environment or {}
 
 Review comment:
   ```suggestion
           self.private_environment = private_environment or {}
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390268570
 
 

 ##########
 File path: airflow/providers/docker/operators/docker.py
 ##########
 @@ -218,7 +224,7 @@ def _run_image(self):
             self.container = self.cli.create_container(
                 command=self.get_command(),
                 name=self.container_name,
-                environment=self.environment,
+                environment={**self.environment, **self._private_environment},
 
 Review comment:
   ```suggestion
                   environment={**self.environment, **self.private_environment},
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #7671: [AIRFLOW-6574] Adding private_environment to docker operator.
URL: https://github.com/apache/airflow/pull/7671#discussion_r390270784
 
 

 ##########
 File path: tests/providers/docker/operators/test_docker.py
 ##########
 @@ -81,13 +83,25 @@ def test_execute(self, client_class_mock, tempdir_mock):
                                                                auto_remove=False,
                                                                dns=None,
                                                                dns_search=None)
-        tempdir_mock.assert_called_once_with(dir='/host/airflow', prefix='airflowtmp')
+        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,
                                                    stderr=True, stream=True)
         client_mock.pull.assert_called_once_with('ubuntu:latest', stream=True)
         client_mock.wait.assert_called_once_with('some_id')
 
+    def test_private_environment_is_private(self):
+        operator = DockerOperator(api_version='1.19', command='env', environment={'UNIT': 'TEST'},
+                                  private_environment={'PRIVATE': 'MESSAGE'}, image='ubuntu:latest',
+                                  network_mode='bridge', owner='unittest', task_id='unittest',
+                                  volumes=['/host/path:/container/path'],
+                                  working_dir='/container/path', shm_size=1000,
+                                  host_tmp_dir='/host/airflow', container_name='test_container',
+                                  tty=True)
+        self.assertEqual(getattr(operator, '_private_environment'), {
+                         'PRIVATE': 'MESSAGE'})
 
 Review comment:
   ```suggestion
           assert operator.private_environment == {'PRIVATE': 'MESSAGE'}
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services