From 5f25dc52a9c5cd8d7ce786d741ad78dd7922def8 Mon Sep 17 00:00:00 2001 From: juri-t Date: Tue, 22 Oct 2024 16:41:05 +0900 Subject: [PATCH] fix: wait 2sec before NewTasksRunningWaiter (#94) --- run.go | 6 ++++++ task/common.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/run.go b/run.go index 21a1c8e..26cc614 100644 --- a/run.go +++ b/run.go @@ -2,6 +2,7 @@ package cage import ( "context" + "time" "github.com/apex/log" "github.com/aws/aws-sdk-go-v2/aws" @@ -46,6 +47,11 @@ func (c *cage) Run(ctx context.Context, input *types.RunInput) (*types.RunResult return nil, err } taskArn := o.Tasks[0].TaskArn + + // NOTE: https://github.com/loilo-inc/canarycage/issues/93 + // wait for the task to be running + time.Sleep(2 * time.Second) + log.Infof("waiting for task '%s' to start...", *taskArn) if err := ecs.NewTasksRunningWaiter(ecsCli).Wait(ctx, &ecs.DescribeTasksInput{ Cluster: &env.Cluster, diff --git a/task/common.go b/task/common.go index 95d64a7..0a79570 100644 --- a/task/common.go +++ b/task/common.go @@ -69,6 +69,11 @@ func (c *common) waitForTaskRunning(ctx context.Context) error { } env := c.di.Get(key.Env).(*env.Envars) ecsCli := c.di.Get(key.EcsCli).(awsiface.EcsClient) + + // NOTE: https://github.com/loilo-inc/canarycage/issues/93 + // wait for the task to be running + time.Sleep(2 * time.Second) + log.Infof("🥚 waiting for canary task '%s' is running...", *c.taskArn) if err := ecs.NewTasksRunningWaiter(ecsCli).Wait(ctx, &ecs.DescribeTasksInput{ Cluster: &env.Cluster,