-
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
FargateService trying to update ECS service when CODE_DEPLOY used #7040
Comments
Hey @adrialucena-seat it appears CodeDeploy Blue/Green deployments are not yet supported in CloudFormation for ECS/Fargate. Related: |
Thank you @sonofachamp , I was already aware of that. That's why I created CodeDeploy application and CodeDeploy deployment group manually in the aws console associating it with the ECS/Fargate service created by CDK. The bug I opened was more related with ECS/Fargate using Blue/Green deployment. When creating a new task definition revision it should trigger the CodeDeploy deployment group associated with that service and not updating the service, as it will fail. |
@sonofachamp as in my previous comment I explained, I think there is no need to wait for the CloudFormation support. What CDK should do when CODE_DEPLOY is specified in Deployment Controller Type in the FargateService class is to trigger the CodeDeploy Deployment Group associated with the ECS Service and not the "update service" that traditionally did. I created the CodeDeploy Deployment Group manually in AWS Console so no need to wait for CloudFormation support. |
Hi, having the same issue and it's not limited to Fargate Services.
But I agree it should be possible to manage the infrastructure, meaning the service config + creation of new taskDefinition revisions with CDK. I haven't investigated what CDK is doing and what's part of Cloudformation. But it seems that one of it sets the newly created taskDefinition revision as active on the service and this is of course not ok when using CodeDeploy for ECS. Is ECS supposed to trigger a CodeDeploy Deployment when a new taskDefinition revision is set as active on the service? I can't find any documentation about it. |
Found a workaround to be able to maintain new task definition revisions with CDK and use Code Deploy with an external CLI command. const taskDefinitionProps = {
cpu: 1024,
memoryLimitMiB: 2048,
}
const taskDefinition = new FargateTaskDefinition(this, 'TaskDefinition', taskDefinitionProps)
const containerDefinitionOptions = {
image: ContainerImage.fromEcrRepository(Repository.fromRepositoryName(this, 'Repository', 'docker'), 'latest'),
environment: {
NAME: 'latest',
},
logging: LogDriver.awsLogs({
logGroup: logGroup,
streamPrefix: 'docker',
}),
}
const container = taskDefinition.addContainer('docker', containerDefinitionOptions)
container.addPortMappings({
containerPort: 80,
})
container.addUlimits({
name: UlimitName.NOFILE,
softLimit: 16384,
hardLimit: 16384,
})
const service = new FargateService(this, 'Service', {
cluster: cluster,
healthCheckGracePeriod: Duration.seconds(60),
minHealthyPercent: 50,
maxHealthyPercent: 200,
deploymentController: {
type: DeploymentControllerType.CODE_DEPLOY,
},
taskDefinition: taskDefinition,
})
const taskDefinitionRev = new FargateTaskDefinition(this, 'TaskDefinitionNew', {
...taskDefinitionProps,
family: taskDefinition.family,
})
const cfnTaskDefinition = taskDefinitionRev.node.defaultChild as CfnTaskDefinition
cfnTaskDefinition.cfnOptions.updateReplacePolicy = CfnDeletionPolicy.RETAIN
const containerRev = taskDefinitionRev.addContainer('docker', {
...containerDefinitionOptions,
environment: {
...containerDefinitionOptions.environment,
NAME: 'docker-new',
},
image: ContainerImage.fromAsset('docker'),
})
containerRev.addPortMappings(...container.portMappings)
containerRev.addUlimits(...container.ulimits) Explanation: Cloudformation would always try to update the current task definition which would lead to an immediate update of the ecs service. This is not possible (currently) when using For automating it the newly created task definition revision can be retrieved from the updated stack which can then be used in a cli call like:
|
Let's wait for #1559 and everything will be fine. |
Hey there, I'm consolidating the issues around ecs blue/green deployment support into #1559. If you think this is a separate issue feel free to reopen. |
The FargateService class is trying to update the ECS Service when a new task definition is provided to the service when
DeploymentControllerType.CODE_DEPLOY
is specified. When using Blue/Green deployment strategy powered by CodeDeploy in a Fargate Service, only the desired count, deployment configuration, and health check grace period can be updated using theupdate-service
. Otherwise a new CodeDeploy deployment should be created.So I haven't been able to do any deploy on production environment with CDK since I use CODE_DEPLOY.
Reproduction Steps
Error Log
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: