【问题标题】:Unable to get ECSOperator (Fargate) to work with Airflow无法让 ECSOperator (Fargate) 与 Airflow 一起工作
【发布时间】:2019-09-06 01:10:00
【问题描述】:

在 Airflow 1.10.1 中使用 ECSOperator 通过 ECS Fargate 运行任务时出现此错误。 DAG 代码可用here

[2019-04-15 15:57:36,960] {{models.py:1788}} ERROR - An error occurred 
(InvalidParameterException) when calling the RunTask operation: Network 
Configuration must be provided when networkMode 'awsvpc' is specified.

不确定那里出了什么问题,因为 network_configuration 是在 args 字典中传递的,类似于这里所做的 https://github.com/apache/airflow/blob/master/tests/contrib/operators/test_ecs_operator.py#L61

【问题讨论】:

    标签: airflow aws-fargate


    【解决方案1】:

    network_configurationAirflow v1.10.3 起已添加到 ESCOperator。我建议将 Airflow 版本升级到 v1.10.3

    参考: https://github.com/apache/airflow/blob/1.10.3/airflow/contrib/operators/ecs_operator.py#L69

    【讨论】:

      【解决方案2】:

      在 ECSOperator 上运行 Fargate 的示例配置 气流版本 - v1.10.3

      def get_ecs_operator_args(param):
          return dict(
      
      launch_type="FARGATE", 
                    # The name of your task as defined in ECS
      
      task_definition="my_automation_task",
                    # The name of your ECS cluster
      
      cluster="my-cluster", 
                    network_configuration={
      
                          'awsvpcConfiguration': {
                                 'securityGroups': ['sg-hijk', 'sg-abcd'],
                                 'subnets': ['subnet-lmn'],
                                 'assignPublicIp': "ENABLED"
                             }
                     }, 
                    overrides = {
                              'containerOverrides': [
                                {
                                     'name': "my-container",
                                     'command': ["python", "myCode.py",
                                                 str(param)]
                                 }
                               ]
                      },
      
      
      region_name="us-east-1")
      
      ecs_args = get_ecs_operator_args("{{ dag_run.conf['name'] }}")
      
      my_operator = ECSOperator( task_id= "task_0",**ecs_args, dag=dag)
      

      【讨论】:

        猜你喜欢
        • 2020-02-29
        • 2011-04-25
        • 2014-11-22
        • 2014-05-15
        • 2010-10-16
        • 2019-11-27
        • 2017-02-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多