Hi there! I have a flow that get run by an ECS Pus...
# ask-community
f
Hi there! I have a flow that get run by an ECS Push work pool. Each time the flow is run (scheduled), it creates a new task definition in my ECS cluster. Is there a way to avoid this? I have configured the
match_latest_revision_in_family
job variable to
True
in an attempt to avoid the creation of new tasks definitions, but had no luck with that. Am I missing something here? Is this happening because the flow runs with different parameters (I have 4 schedules for the same deployment, each with different parameters)? This "problem" is making some flow runs to fail with the following error message:
Copy code
Flow run could not be submitted to infrastructure: An error occurred (ClientException) when calling the RegisterTaskDefinition operation: Too many concurrent attempts to create a new revision of the specified family.
@Marvin
m
thought for 48.2 seconds
Based on the research and GitHub issues, I can provide some clarity on your situation: 1. Root Cause: The issue you're experiencing is a known behavior where Prefect creates new task definition revisions for each flow run, even when the configuration is largely the same. This happens because: - Prefect includes the flow run name in the task definition (as the
awslogs-stream-prefix
) - Different parameters can trigger new task definition creation - The
match_latest_revision_in_family
setting doesn't fully prevent this behavior 2. Current Limitations: - AWS has a rate limit on the
RegisterTaskDefinition
operation - When multiple flows are scheduled close together, this can trigger the "Too many concurrent attempts" error you're seeing 3. Potential Workarounds: a. Spread Out Schedules: If possible, stagger your schedules to avoid concurrent task definition registrations b. Use Pre-registered Task Definitions: You can pre-register a task definition and configure your work pool to use it c. Consolidate Schedules: Consider if you can combine some of your schedules and handle the different parameters within the flow logic instead 4. Best Practice Solution: Here's how you can modify your work pool configuration to use a pre-registered task definition:
Copy code
yaml
work_pool:
  name: your-ecs-pool
  job_variables:
    task_definition_arn: "arn:aws:ecs:region:account:task-definition/your-task-definition:1"
    family: "your-task-family"
    # Other configurations...
The key is to: 1. Pre-register your task definition in AWS ECS 2. Use that task definition's ARN in your work pool configuration 3. Keep the family name consistent This approach should help you avoid the task definition registration rate limit issues while still allowing you to run your flow with different parameters. Note: This is an active issue in the Prefect community, and there are ongoing discussions about improving this behavior. You might want to follow this GitHub issue for updates. Would you like me to provide more specific details about any of these workarounds, or would you like to explore a particular solution further?
j
Hey, I don't believe the push work pool supports
match_latest_revision_in_family
. But you should definitely not be getting a different revision with every flow run, unless you are making infra level configuration changes dynamically on every single flow run. It should be using the latest revision for a given workpool/deployment combo at a time. Can you see what the diff is between one task revision and the next in the same family? That should give an idea of why it's generating a new one. You also always have the option to create your own task definition manually and just pass the arn, then a new revision will never be created.
f
@Jake Kaplan Thanks for your help! Leaving my notes here in case it helps someone else in the future. I followed your advice and checked the diff between revisions - turns out the flow run name was being passed as part of the log configuration by default. Since that name changes with every run, it was triggering the creation of a new task revision each time. I resolved it by manually creating a new task definition and passing the ARN directly.