This is an automated email from the ASF dual-hosted git repository.

onikolas 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 5fb0d65aaf Adding support for volume configurations in 
ECSRunTaskOperator (#42087)
5fb0d65aaf is described below

commit 5fb0d65aaf0ddf426b494c14f7ca82d4d5cc23ab
Author: Shoaib UR Rehman <[email protected]>
AuthorDate: Thu Sep 12 00:25:55 2024 +0500

    Adding support for volume configurations in ECSRunTaskOperator (#42087)
    
    * Adding support for volume configurations in ECSRunTaskOperator
    
    * Updating template fields override test to include volume_configurations
    
    ---------
    
    Co-authored-by: glory9211 <[email protected]>
---
 airflow/providers/amazon/aws/operators/ecs.py    | 9 +++++++++
 tests/providers/amazon/aws/operators/test_ecs.py | 1 +
 2 files changed, 10 insertions(+)

diff --git a/airflow/providers/amazon/aws/operators/ecs.py 
b/airflow/providers/amazon/aws/operators/ecs.py
index 1cd8685cf2..433fd88cd6 100644
--- a/airflow/providers/amazon/aws/operators/ecs.py
+++ b/airflow/providers/amazon/aws/operators/ecs.py
@@ -373,6 +373,10 @@ class EcsRunTaskOperator(EcsBaseOperator):
         When capacity_provider_strategy is specified, the launch_type 
parameter is omitted.
         If no capacity_provider_strategy or launch_type is specified,
         the default capacity provider strategy for the cluster is used.
+    :param volume_configurations: the volume configurations to use when using 
capacity provider. The name of the volume must match
+                                  the name from the task definition.
+                                  You can configure the settings like size, 
volume type, IOPS, throughput and others mentioned in
+                                  
(https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_TaskManagedEBSVolumeConfiguration.html)
     :param group: the name of the task group associated with the task
     :param placement_constraints: an array of placement constraint objects to 
use for
         the task
@@ -420,6 +424,7 @@ class EcsRunTaskOperator(EcsBaseOperator):
         "overrides",
         "launch_type",
         "capacity_provider_strategy",
+        "volume_configurations",
         "group",
         "placement_constraints",
         "placement_strategy",
@@ -450,6 +455,7 @@ class EcsRunTaskOperator(EcsBaseOperator):
         overrides: dict,
         launch_type: str = "EC2",
         capacity_provider_strategy: list | None = None,
+        volume_configurations: list | None = None,
         group: str | None = None,
         placement_constraints: list | None = None,
         placement_strategy: list | None = None,
@@ -479,6 +485,7 @@ class EcsRunTaskOperator(EcsBaseOperator):
         self.overrides = overrides
         self.launch_type = launch_type
         self.capacity_provider_strategy = capacity_provider_strategy
+        self.volume_configurations = volume_configurations
         self.group = group
         self.placement_constraints = placement_constraints
         self.placement_strategy = placement_strategy
@@ -614,6 +621,8 @@ class EcsRunTaskOperator(EcsBaseOperator):
 
         if self.capacity_provider_strategy:
             run_opts["capacityProviderStrategy"] = 
self.capacity_provider_strategy
+            if self.volume_configurations is not None:
+                run_opts["volumeConfigurations"] = self.volume_configurations
         elif self.launch_type:
             run_opts["launchType"] = self.launch_type
         if self.platform_version is not None:
diff --git a/tests/providers/amazon/aws/operators/test_ecs.py 
b/tests/providers/amazon/aws/operators/test_ecs.py
index a6915214a0..fefdb595da 100644
--- a/tests/providers/amazon/aws/operators/test_ecs.py
+++ b/tests/providers/amazon/aws/operators/test_ecs.py
@@ -172,6 +172,7 @@ class TestEcsRunTaskOperator(EcsBaseTestCase):
             "overrides",
             "launch_type",
             "capacity_provider_strategy",
+            "volume_configurations",
             "group",
             "placement_constraints",
             "placement_strategy",

Reply via email to