airflow icon indicating copy to clipboard operation
airflow copied to clipboard

EcsRegisterTaskDefinitionOperator params are incorrectly invalidated

Open janrito opened this issue 2 years ago • 6 comments

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

https://raw.githubusercontent.com/apache/airflow/constraints-2.4.3/constraints-3.10.txt

Apache Airflow version

2.4.3

Operating System

https://github.com/aws/aws-mwaa-local-runner / on macos 12.6

Deployment

Docker-Compose

Deployment details

local

What happened

ECS task definition cpu and memory params are incorrectly invalidated

What you think should happen instead

parameters are correct, it should register a task. I can run the same bit of code using boto3.client.ecs.register_task_definition`

How to reproduce

Try and define a task using:

EcsRegisterTaskDefinitionOperator(
        task_id="register_task",
        family=TASK_FAMILY_NAME,
        container_definitions=[
            {
                "name": CONTAINER_NAME,
                "image": "ubuntu",
                "workingDirectory": "/usr/bin",
                "entryPoint": ["sh", "-c"],
                "command": ["ls"],
            }
        ],
        register_task_kwargs={
            "requiresCompatibilities": ["FARGATE"],
            "cpu": "256",
            "memory": "512",
            "networkMode": "awsvpc",
        },
    )
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid type for parameter cpu, value: 256, type: <class 'int'>, valid types: <class 'str'>
Invalid type for parameter memory, value: 512, type: <class 'int'>, valid types: <class 'str'>

Could this error have something to do with JSON serialising/deserialising where the parameters are autodetected as ints, rather than deserialised into strings

Anything else

No response

Are you willing to submit PR?

  • [ ] Yes I am willing to submit a PR!

Code of Conduct

janrito avatar Feb 20 '23 13:02 janrito

Thanks for opening your first issue here! Be sure to follow the issue template!

boring-cyborg[bot] avatar Feb 20 '23 13:02 boring-cyborg[bot]

Not a bug Airflow provider, the validation happen inside botocore / boto3, see available options and types in ECS.Client.register_task_definition

Taragolis avatar Feb 20 '23 14:02 Taragolis

Nevermind, I have a look on wrong parameters initially. Did you use specific values such as render_template_as_native_obj=True in DAG?

Taragolis avatar Feb 20 '23 14:02 Taragolis

Ah! yes. I did. Why is that clashing?

janrito avatar Feb 20 '23 14:02 janrito

register_task_kwargs it is templated field which evaluate thought jinja and I with this settings NativeEnvironment transform "512" to 512 even if it not not contain jinja blocks

Taragolis avatar Feb 20 '23 17:02 Taragolis

This issue has been automatically marked as stale because it has been open for 365 days without any activity. There has been several Airflow releases since last activity on this issue. Kindly asking to recheck the report against latest Airflow version and let us know if the issue is reproducible. The issue will be closed in next 30 days if no further activity occurs from the issue author.

github-actions[bot] avatar Feb 21 '24 07:02 github-actions[bot]

This issue has been closed because it has not received response from the issue author.

github-actions[bot] avatar Mar 23 '24 07:03 github-actions[bot]