-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ecs): support availability zone rebalancing #32263
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32263 +/- ##
=======================================
Coverage 81.52% 81.52%
=======================================
Files 222 222
Lines 13715 13715
Branches 2417 2417
=======================================
Hits 11181 11181
Misses 2254 2254
Partials 280 280
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hi @pahud, I saw you added an I have not used the patterns myself before, and when I took a look at them, I wasn't sure if I should default this feature to be enabled in services created by those patterns. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've made some comments.
* | ||
* @param loadBalancer [disable-awslint:ref-via-interface] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not see many cases of overriding functions from a base class in CDK.
Perhaps it’s more common to define an interface in a base-service.ts
file and have each subclass implement it. Please consider discussing this with the maintainers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attachToClassicLB
is already on an interface, ILoadBalancerTarget
:
aws-cdk/packages/aws-cdk-lib/aws-elasticloadbalancing/lib/load-balancer.ts
Lines 144 to 153 in 92d03e2
/** | |
* Interface that is going to be implemented by constructs that you can load balance to | |
*/ | |
export interface ILoadBalancerTarget extends IConnectable { | |
/** | |
* Attach load-balanced target to a classic ELB | |
* @param loadBalancer [disable-awslint:ref-via-interface] The load balancer to attach the target to | |
*/ | |
attachToClassicLB(loadBalancer: LoadBalancer): void; | |
} |
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts
Lines 511 to 512 in 92d03e2
export abstract class BaseService extends Resource | |
implements IBaseService, elbv2.IApplicationLoadBalancerTarget, elbv2.INetworkLoadBalancerTarget, elb.ILoadBalancerTarget { |
IIRC (I wrote this ~6 weeks ago 🌞) I had to disable this lint in order to be able to call super
from the overriding methods. I need to call super
because it refers to this private getter:
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/base/base-service.ts
Lines 1454 to 1458 in 92d03e2
private get defaultLoadBalancerTarget() { | |
return this.loadBalancerTarget({ | |
containerName: this.taskDefinition.defaultContainer!.containerName, | |
}); | |
} |
This PR has been in the MERGE CONFLICTS state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
ea590d6
to
52b9a58
Compare
if (!Token.isUnresolved(props.maxHealthyPercent) && props.maxHealthyPercent === 100) { | ||
throw new Error('AvailabilityZoneRebalancing.ENABLED requires maxHealthyPercent > 100'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that by defining availabilityZoneRebalancing
in BaseServiceOptions
, all validations for maxHealthyPercent
and those in attachToClassicLB()
could be described in the BaseService
class.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BaseService is also extended by ExternalService, where AvailabilityZoneRebalancing is not a supported feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
app.synth()
in the integ test code is not necessary. Please remove those lines!
...aws-cdk-testing/framework-integ/test/aws-ecs/test/ec2/integ.availability-zone-rebalancing.ts
Outdated
Show resolved
Hide resolved
...cdk-testing/framework-integ/test/aws-ecs/test/fargate/integ.availability-zone-rebalancing.ts
Outdated
Show resolved
Hide resolved
Add `availabilityZoneRebalancing` to the props of FargateService and Ec2Service, and validate all the documented constraints on it being `ENABLED`.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Issue # (if applicable)
Closes #32226
Reason for this change
New AZ rebalancing feature is not yet supported in L2 constructs.
Description of changes
Add
availabilityZoneRebalancing
to the props of FargateService and Ec2Service, and validate all the documented constraints on it beingENABLED
.Description of how you validated changes
Unit and integration tests.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license