Skip to content

Commit

Permalink
fix canary task stop
Browse files Browse the repository at this point in the history
  • Loading branch information
takkyuuplayer committed Apr 10, 2024
1 parent 010af2a commit a94d644
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
14 changes: 6 additions & 8 deletions rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ func (c *cage) RollOut(ctx context.Context) (*RollOutResult, error) {
)
}
}(canaryTask, ret)

log.Infof("😷 ensuring canary task container(s) to become healthy...")
if err := c.waitUntilContainersBecomeHealthy(ctx, *canaryTask.task.TaskArn, nextTaskDefinition); err != nil {
return nil, err
}

log.Infof("canary task '%s' ensured.", *canaryTask.task.TaskArn)
if targetGroupArn != nil {
log.Infof("😷 ensuring canary task to become healthy...")
Expand Down Expand Up @@ -286,14 +292,7 @@ func (c *cage) StartCanaryTask(ctx context.Context, nextTaskDefinition *ecstypes
}, WaitDuration); err != nil {
return nil, err
}

log.Infof("🥚 waiting until canary task '%s' containers become healthy...", *taskArn)
if err := c.waitUntilContainersBecomeHealthy(ctx, *taskArn, nextTaskDefinition); err != nil {
return nil, err
}

log.Infof("🐣 canary task '%s' is running!️", *taskArn)

var task ecstypes.Task
if o, err := c.ecs.DescribeTasks(ctx, &ecs.DescribeTasksInput{
Cluster: &c.env.Cluster,
Expand All @@ -303,7 +302,6 @@ func (c *cage) StartCanaryTask(ctx context.Context, nextTaskDefinition *ecstypes
} else {
task = o.Tasks[0]
}

if len(service.LoadBalancers) == 0 {
log.Infof("no load balancer is attached to service '%s'. skip registration to target group", *service.ServiceName)
log.Infof("wait %d seconds for ensuring the task goes stable", c.env.CanaryTaskIdleDuration)
Expand Down
6 changes: 6 additions & 0 deletions rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ func TestCage_RollOut_FARGATE(t *testing.T) {
ctx := context.Background()
_, err := cagecli.RollOut(ctx)
assert.NotNil(t, err)

for _, task := range mocker.Tasks {
if strings.Contains(*task.Group, "canary-task") {
assert.Equal(t, "STOPPED", *task.LastStatus)
}
}
})
}

Expand Down

0 comments on commit a94d644

Please sign in to comment.