Skip to content

(aws-ecs): shouldUseCircuitBreaker warning is emitted for DAEMON scheduling-strategy services, where the deployment circuit breaker doesn't apply #38102

Description

@shorn

Describe the bug

The @aws-cdk/aws-ecs:shouldUseCircuitBreaker warning ("Enable the 'circuitBreaker' property to trigger a quicker deployment failure...") is emitted for an Ec2Service created with daemon: true (DAEMON scheduling strategy).

The ECS deployment circuit breaker is not applicable to daemon services: its failure threshold is defined as 0.5 × desiredCount (min 3, max 200), and a daemon service has no desired count (it runs one task per instance). The circuit breaker is documented for rolling-update replica services. So this warning is a false positive — following its advice (setting circuitBreaker) is meaningless for a daemon service, and the only way to make it go away is to acknowledgeWarning(...) advice that doesn't apply.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

No shouldUseCircuitBreaker warning is emitted for services using the DAEMON scheduling strategy.

Current Behavior

The warning is emitted on synth for daemon services:

[Warning at /Stack/DaemonService] Enable the 'circuitBreaker' property to trigger a quicker deployment failure if tasks are failing to come start (without this setting deployments may take up to 3 hours to fail). [ack: @aws-cdk/aws-ecs:shouldUseCircuitBreaker]

Reproduction Steps

const vpc = new ec2.Vpc(this, 'Vpc');
const cluster = new ecs.Cluster(this, 'Cluster', { vpc });
cluster.addCapacity('Cap', { instanceType: new ec2.InstanceType('t3.micro') });

const taskDef = new ecs.Ec2TaskDefinition(this, 'TaskDef');
taskDef.addContainer('c', {
  image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
  memoryReservationMiB: 128,
});

new ecs.Ec2Service(this, 'DaemonService', {
  cluster,
  taskDefinition: taskDef,
  daemon: true, // DAEMON scheduling strategy
  // no circuitBreaker -> warning is emitted even though it cannot apply
});

Run cdk synth and observe the warning on DaemonService.

Possible Solution

The warning is emitted in BaseService (aws-ecs/lib/base/base-service.ts), guarded only by !props.circuitBreaker && this.isEcsDeploymentController — with no checkfor the scheduling strategy. The daemon/scheduling-strategy information is only set in the Ec2Service subclass, so BaseService never accounts for it.

Suggested fix: suppress shouldUseCircuitBreaker when the service uses the DAEMON scheduling strategy. CDK already special-cases daemon services elsewhere (it validatesdesiredCount, placement strategies, and AZ-rebalancing against daemon mode, and has a dedicated @aws-cdk/aws-ecs:minHealthyPercentDaemon warning — #31705), so thisis an inconsistency rather than intended behaviour. Related signal-vs-noise precedent for an unsuppressable circuit-breaker-adjacent warning: #10059.

The circuit breaker requires the ECS (rolling-update) deployment controller, which daemon services do use — so isEcsDeploymentController is true and the warning fires — but the breaker itself is desired-count based and isn't meaningful for daemon scheduling.

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

"aws-cdk-lib": "2.258.0"

AWS CDK CLI version

"aws-cdk": "2.1126.0"

Node.js Version

v26.2.0

OS

Windows 10

Language

TypeScript

Language Version

Typescript 5.8.3

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.effort/smallSmall work item – less than a day of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions