b

    Baptiste M

    1 year ago
    Hello, I'm having some trouble with prefect agent when starting task. I don't really know why this error suddenly occurred, my flow used to work fine and I made some changes on my flow but not on the RunConf...
    [2021-04-26 09:20:28,684] INFO - fargate-launch | Found 1 flow run(s) to submit for execution.
    [2021-04-26 09:20:31,589] INFO - fargate-launch | Deploying flow run '6021f038-6c79-4e78-862a-e29143f7d205'
    [2021-04-26 09:20:31,590] ERROR - fargate-launch | Logging platform error for flow run 6021f038-6c79-4e78-862a-e29143f7d205
    [2021-04-26 09:20:34,079] ERROR - fargate-launch | Error while deploying flow
    Traceback (most recent call last):
      File "/home/ubuntu/.local/lib/python3.8/site-packages/prefect/agent/agent.py", line 414, in deploy_and_update_flow_run
        deployment_info = self.deploy_flow(flow_run)
      File "/home/ubuntu/.local/lib/python3.8/site-packages/prefect/agent/ecs/agent.py", line 296, in deploy_flow
        taskdef = self.generate_task_definition(flow_run, run_config)
      File "/home/ubuntu/.local/lib/python3.8/site-packages/prefect/agent/ecs/agent.py", line 370, in generate_task_definition
        taskdef["family"] = f"prefect-{slug}"
    TypeError: 'str' object does not support item assignment
    Do you have any idea ? I didn't try to restart the agent, because I want to find the reason of this failure without resolving it just with a restart. Thanks !
    Kevin Kho

    Kevin Kho

    1 year ago
    Hi @Baptiste M! Just a friendly reminder to move the log into the thread next time to not crowd the Slack channel. I believe you need to remove the “f” from f”prefect-{slug}". You can’t use f-strings with templating.
    b

    Baptiste M

    1 year ago
    Oh sorry about the log... Hum I would like to remove the f, but it's not my code... This code come from prefect/agent/ecs/agent.py which is yours
    Kevin Kho

    Kevin Kho

    1 year ago
    Oh I see. My bad. I’ll look into it more.
    What version of Prefect are you using to register the flow and what version is on the image?
    b

    Baptiste M

    1 year ago
    I found something. I had the following line on my ECSRun config.
    RUN_CONFIG = ECSRun(
        task_definition="prefect-importrawdataflow",
    ...
    )
    I removed the "prefect-" and now it works... But I don't know why. I use the same image to register the flow and to execute the flow. With a prefect 0.14.15 installed
    Kevin Kho

    Kevin Kho

    1 year ago
    I think task_definition should be a Dict of the task parameters (cpu, memory, networkMode, executionroleARN)
    Can I see your full ECSRun?
    Remove any sensitive info
    b

    Baptiste M

    1 year ago
    Yes
    RUN_CONFIG = ECSRun(
        labels=["s3-flow-storage"],
        task_role_arn=TASK_ARN,
        image="******.<http://dkr.ecr.eu-west-3.amazonaws.com/*****|dkr.ecr.eu-west-3.amazonaws.com/*****>",
        run_task_kwargs=RUN_TASK_KWARGS,
        task_definition="importrawdataflow",
        execution_role_arn="arn:aws:iam::*****:role/ECSTasksAllowS3AndECR",
        cpu="2 vcpu",
        memory="4 GB"
    )
    Here I removed the "prefect-" that was before "importrawdataflow" on task_definition
    Kevin Kho

    Kevin Kho

    1 year ago
    The task_definition should be a dictionary that looks like this . Maybe you can try
    task_definition={"containerDefinitions":[{"name": "importrawdataflow"}]}
    This is a good example .
    b

    Baptiste M

    1 year ago
    Hum ok I see. I will try this. Thanks for your help !
    Kevin Kho

    Kevin Kho

    1 year ago
    Here is their definition . You can try running that to get the format you want. No problem!