Skip to content

Commit

Permalink
fix: only restart ecs tasks if new ones cannot start due to config (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jun 19, 2024
1 parent cc9fc28 commit 3262266
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cd/manager/common/aws/ecs/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,11 @@ func (e Ecs) updateEcsService(cluster, service, image, containerName string, tem
if _, err = e.ecsClient.UpdateService(ctx, updateSvcInput); err != nil {
log.Printf("updateEcsService: update service error: %s, %s, %s, %s, %v, %v", cluster, service, image, newTaskDefArn, tempTask, err)
return "", err
} else if !tempTask {
// Stop all permanently running tasks in the service
} else
// Stop any permanently running tasks in the service if the deployment requires only a single instance of the
// service task to run. We use the latter configuration in special cases where the application cannot support
// running more than one instance of a service task at a time. Otherwise, ECS can manage the deployment for us.
if !tempTask && (*descSvcOutput.Services[0].DeploymentConfiguration.MaximumPercent < 200) {
if err = e.stopEcsTasks(cluster, e.taskFamilyFromArn(newTaskDefArn)); err != nil {
log.Printf("updateEcsService: stop tasks error: %s, %s, %s, %s, %v, %v", cluster, service, image, newTaskDefArn, tempTask, err)
return "", err
Expand All @@ -373,7 +376,8 @@ func (e Ecs) updateEcsTask(cluster, familyPfx, image, containerName string, temp
return "", err
} else {
if !tempTask {
// Stop all permanently running tasks in the service
// Stop all permanently running tasks in the service. Since there is no deployment configuration for tasks,
// we can't rely on ECS to manage the deployment for us.
if err = e.stopEcsTasks(cluster, e.taskFamilyFromArn(newTaskDefArn)); err != nil {
log.Printf("updateEcsTask: stop tasks error: %s, %s, %s, %s, %s, %v, %v", cluster, familyPfx, image, prevTaskDefArn, newTaskDefArn, tempTask, err)
return "", err
Expand Down

0 comments on commit 3262266

Please sign in to comment.