fix(aws-ecs): suppress shouldUseCircuitBreaker warning for DAEMON scheduling services#38250
Conversation
…services The shouldUseCircuitBreaker warning was emitted for Ec2Service and ExternalService instances created with daemon: true. The ECS circuit breaker is not applicable to DAEMON services: its failure threshold is 0.5 × desiredCount (min 3, max 200), and a DAEMON service has no desired count (one task per instance). Following the advice is meaningless, and the only way to silence it was to acknowledgeWarning with text that doesn't apply. Guard the warning with additionalProps.schedulingStrategy !== 'DAEMON', which is already set by both Ec2Service and ExternalService when daemon: true. Fixes aws#38102
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
❌ The title scope of the pull request should omit 'aws-' from the name of modified packages. Use 'ecs' instead of 'aws-ecs'.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
There was a problem hiding this comment.
Pull request overview
This PR fixes a false-positive ECS warning by suppressing the @aws-cdk/aws-ecs:shouldUseCircuitBreaker recommendation for services using the DAEMON scheduling strategy, where the deployment circuit breaker is not meaningful.
Changes:
- Guard the
shouldUseCircuitBreakerwarning inBaseServiceso it doesn’t fire forschedulingStrategy: 'DAEMON'. - Add a regression test ensuring
Ec2Servicewithdaemon: truedoes not emit the circuit breaker suggestion.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts | Adds a DAEMON scheduling-strategy guard to prevent emitting an inapplicable circuit breaker warning. |
| packages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts | Adds a regression test asserting the circuit breaker suggestion warning is not emitted for daemon services. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const warnings = flattenMeta(app.synth().getStackByName('Stack').metadata)['/Stack/Ec2Service']['aws:cdk:warning']; | ||
| expect(warnings ?? []).not.toContainEqual(expect.stringContaining("Enable the 'circuitBreaker' property")); |
Summary
Closes #38102
Problem: The
@aws-cdk/aws-ecs:shouldUseCircuitBreakerwarning is emitted forEc2ServiceandExternalServiceinstances created withdaemon: true. The warning says to enable thecircuitBreakerproperty, but the ECS circuit breaker doesn't apply to DAEMON services: its failure threshold is defined as0.5 × desiredCount(min 3, max 200), and a DAEMON service has no desired count — it runs one task per instance. Following the advice is meaningless, and the only way to suppress the warning today isacknowledgeWarning(...)on text that doesn't apply.Fix: Add a
schedulingStrategy !== 'DAEMON'guard to the warning condition inBaseService. BothEc2ServiceandExternalServicealready passschedulingStrategy: props.daemon ? 'DAEMON' : ...viaadditionalProps, so the existing field covers both callers with no interface changes.Changes
packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts— one-line condition guardpackages/aws-cdk-lib/aws-ecs/test/ec2/ec2-service.test.ts— regression test asserting no circuit breaker warning fordaemon: trueservicesTesting
All existing circuit breaker tests still pass (the warning still fires for non-daemon ECS services as before).