Bug summary
Problem
When using custom job configurations with multiple container definitions, the Prefect ECS worker re-registers task definitions even when they are identical. This occurs when the essential field is not explicitly set on container definitions.
Root Cause
AWS ECS sets essential to True for containers if it's not specified at Task Definition registration time.
When comparing task definitions:
- The generated task definition from Prefect may not have
essential set on all containers
- The task definition retrieved from AWS has
essential values set by AWS defaults
- The comparison logic in
_task_definitions_equal() wasn't normalizing the essential field correctly
- This mismatch causes the comparison to fail, leading to unnecessary re-registration
Additional Issue
essential: False is removed from container definitions
The _drop_empty_keys_from_dict function removes boolean False values from task definitions, causing essential: False to be stripped from container definitions before registration with AWS. AWS then defaults essential to True, changing the intended behavior.
Version info
Additional context
Example Configuration
This issue affects customers using custom job configurations like:
task_definition:
containerDefinitions:
- name: "prefect"
image: "{{ image }}"
- name: "datadog-agent"
image: "public.ecr.aws/datadog/agent:latest"
Bug summary
Problem
When using custom job configurations with multiple container definitions, the Prefect ECS worker re-registers task definitions even when they are identical. This occurs when the
essentialfield is not explicitly set on container definitions.Root Cause
AWS ECS sets
essentialto True for containers if it's not specified at Task Definition registration time.When comparing task definitions:
essentialset on all containersessentialvalues set by AWS defaults_task_definitions_equal()wasn't normalizing theessentialfield correctlyAdditional Issue
essential: Falseis removed from container definitionsThe
_drop_empty_keys_from_dictfunction removes booleanFalsevalues from task definitions, causingessential: Falseto be stripped from container definitions before registration with AWS. AWS then defaultsessentialtoTrue, changing the intended behavior.Version info
Additional context
Example Configuration
This issue affects customers using custom job configurations like: