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/12/09 15:28:43 UTC

[GitHub] [airflow] hammad13060 opened a new pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

hammad13060 opened a new pull request #12952:
URL: https://github.com/apache/airflow/pull/12952


   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   This PR adds support for `capacityProviderStrategy `option in ECSOperator. AWS docs for starting a new ECS task via the `RunTask` API mention that If a `capacityProviderStrategy` is specified, the `launchType` parameter must be omitted. If no `capacityProviderStrategy` or` launchType` is specified, the `defaultCapacityProviderStrategy` for the cluster is used. More details [here](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_RunTask.html#API_RunTask_RequestSyntax). So, logic takes care of this by omitting/ignoring the `launchType` if `capacityProviderStrategy` is specified.
   
   closes: #8381 
   
   
   Also, I'd like to know if manual testing by creating an ECS task on AWS cloud is required for this feqture?
   
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   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).
   


----------------------------------------------------------------
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



[GitHub] [airflow] github-actions[bot] commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-791054942


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.


----------------------------------------------------------------
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



[GitHub] [airflow] mik-laj commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
mik-laj commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-741901392


   @mik-laj For now, most contributors are focused on Airflow 2.0. We still have a few things to do. Can you remind us of this change next week?
   
   I also think it's a good idea to ask Subash Canapathy on Slack for reviews.
   


----------------------------------------------------------------
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



[GitHub] [airflow] hammad13060 commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
hammad13060 commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-747241563


   @mik-laj please have a look whenever possible.


----------------------------------------------------------------
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



[GitHub] [airflow] mauritsderuiter95 commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
mauritsderuiter95 commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-754486512


   What is the status of this 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



[GitHub] [airflow] hammad13060 commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
hammad13060 commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-741898633


   @mik-laj please have a look at the first draft whenever possible.


----------------------------------------------------------------
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



[GitHub] [airflow] feluelle commented on a change in pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
feluelle commented on a change in pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#discussion_r559350937



##########
File path: airflow/providers/amazon/aws/operators/ecs.py
##########
@@ -207,7 +213,9 @@ def _start_task(self):
             'startedBy': self.owner,
         }
 
-        if self.launch_type:
+        if self.capacity_provider_strategy is not None:

Review comment:
       ```suggestion
           if self.capacity_provider_strategy:
   ```

##########
File path: tests/providers/amazon/aws/operators/test_ecs.py
##########
@@ -94,28 +94,50 @@ def test_template_fields_overrides(self):
 
     @parameterized.expand(
         [
-            ['EC2', None],
-            ['FARGATE', None],
-            ['EC2', {'testTagKey': 'testTagValue'}],
-            ['', {'testTagKey': 'testTagValue'}],
+            ['EC2', None, None],
+            ['FARGATE', None, None],
+            ['EC2', {'testTagKey': 'testTagValue'}, None],
+            ['', {'testTagKey': 'testTagValue'}, None],
+            [None, None, [{'capacityProvider': 'FARGATE_SPOT', 'weight': 123, 'base': 123}]],
+            [
+                None,
+                {'testTagKey': 'testTagValue'},
+                [{'capacityProvider': 'FARGATE_SPOT', 'weight': 123, 'base': 123}],
+            ],
+            [
+                'FARGATE',
+                {'testTagKey': 'testTagValue'},
+                [{'capacityProvider': 'FARGATE_SPOT', 'weight': 123, 'base': 123}],
+            ],
+            [
+                'EC2',
+                {'testTagKey': 'testTagValue'},
+                [{'capacityProvider': 'FARGATE_SPOT', 'weight': 123, 'base': 123}],
+            ],
         ]
     )
     @mock.patch.object(ECSOperator, '_wait_for_task_ended')
     @mock.patch.object(ECSOperator, '_check_success_task')
-    def test_execute_without_failures(self, launch_type, tags, check_mock, wait_mock):
+    def test_execute_without_failures(
+        self, launch_type, tags, capacity_provider_strategy, check_mock, wait_mock
+    ):
 
-        self.set_up_operator(launch_type=launch_type, tags=tags)  # pylint: disable=no-value-for-parameter
+        self.set_up_operator(  # pylint: disable=no-value-for-parameter
+            launch_type=launch_type, tags=tags, capacity_provider_strategy=capacity_provider_strategy
+        )
         client_mock = self.aws_hook_mock.return_value.get_conn.return_value
         client_mock.run_task.return_value = RESPONSE_WITHOUT_FAILURES
 
         self.ecs.execute(None)
 
         self.aws_hook_mock.return_value.get_conn.assert_called_once()
         extend_args = {}
-        if launch_type:
+        if capacity_provider_strategy is not None:
+            extend_args['capacityProviderStrategy'] = capacity_provider_strategy
+        elif launch_type:
             extend_args['launchType'] = launch_type
-        if launch_type == 'FARGATE':
-            extend_args['platformVersion'] = 'LATEST'
+            if launch_type == 'FARGATE':
+                extend_args['platformVersion'] = 'LATEST'
         if tags:
             extend_args['tags'] = [{'key': k, 'value': v} for (k, v) in tags.items()]

Review comment:
       Can we pass extended args as a parameter to `@parameterized.expand`? i.e. so that we define what extended args we expect - instead of defining the **same** `if, elif, else` _business_ logic in the tests.
   
   A test generally has input and output. It should not reproduce the exact behaviour of the code you want to test.




----------------------------------------------------------------
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



[GitHub] [airflow] boring-cyborg[bot] commented on pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on pull request #12952:
URL: https://github.com/apache/airflow/pull/12952#issuecomment-741845374


   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, pylint and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/master/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/master/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/master/BREEZE.rst) for testing locally, itโ€™s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better ๐Ÿš€.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


----------------------------------------------------------------
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



[GitHub] [airflow] github-actions[bot] closed pull request #12952: Add support for capacityProviderStrategy option in ECSOperator.

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #12952:
URL: https://github.com/apache/airflow/pull/12952


   


----------------------------------------------------------------
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