Hey there! I noticed an extensive <conversation> a...
# ask-community
m
Hey there! I noticed an extensive conversation around using the
ECSRun
run configuration, with
ECSAgent
and
Docker
storage. I am running into a similar issue - not entirely sure if there is a workaround currently, but here is the error I cannot get past:
Copy code
[2021-03-31 15:09:51,907] ERROR - agent | Error while deploying flow: InvalidParameterException('An error occurred (InvalidParameterException) when calling the RunTask operation: Task definition does not support launch_type FARGATE.')
My setup:
Copy code
# flow.py

import prefect
from prefect import Flow, task

@task
def say_hello():
    logger = prefect.context.get("logger")
    <http://logger.info|logger.info>("Got here!!!!")

with Flow("Test") as flow:
    say_hello()
--
Copy code
# deploy.py

flow.run_configs = ECSRun(
    run_task_kwargs={'cluster': 'my-cluster'},
    execution_role_arn='arn:aws:iam::{ACCOUNT_NUMBER}:role/my-ecs-task-role',
    labels=['ecs']
)

flow.storage = Docker(
    env_vars=config.ENVIRONMENT_VARIABLES,
    extra_dockerfile_commands=[
        f"RUN pip install -e /service",
    ],
    files={f"{os.path.join(os.path.expanduser('~'), 'project')}": "/service"},
    image_name=config.DOCKER_IMAGE_NAME,
    image_tag=config.DOCKER_IMAGE_TAG,
    registry_url=config.DOCKER_REGISTRY_URL,
)
Here is how I am running the agent:
Copy code
prefect agent ecs start --token {PREFECT_RUNNER_TOKEN} --cluster my-cluster --label ecs --launch-type FARGATE
My issue is, I have no idea if I am doing something wrong on the AWS side of things or not; I am trying to wrap my head around the root cause. I’m also noticing there are
task_definitions
and
task_role_arn
parameters and I’m unsure if I am expected to use them or not, where to set those up. Any insight would be extremely appreciated!
j
This is a known bug that shows up in some configurations. I recently got a reproducible example last night, currently debugging now.
So there's nothing wrong with what you're doing, but I don't have a suggested workaround for now, should hopefully get things fixed for next release.
👍 1
m
Totally understood!
@Jim Crist-Harif is this a newly introduced bug with updates to 14x Prefect versions?
j
I'm not sure yet. Prefect 0.14.12 made some changes to the ECS agent, but none that I'd expect to cause this issue. If you want to try 0.14.11 and see if that works for you, that'd be helpful for debugging.
m
I just realized I’m actually running against 0.14.6
j
m
Running against your branch, I’m hitting
Copy code
botocore.errorfactory.ClientException: An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Fargate requires task definition to have execution role ARN to support ECR images.
but I think thats on my end… testing some things currently.
Can’t seem to get past it
j
That's saying you need to configure an execution role for your flow (or on the agent). This can be done by passing
execution_role_arn
to
ECSRun
or using the
--execution-role-arn
flag on the agent.