From 6b0499cd255b253327d6ce173e50f58a762b5f3e Mon Sep 17 00:00:00 2001 From: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> Date: Fri, 25 Aug 2023 17:53:15 +0700 Subject: [PATCH] Cherry-pick #4564 #4567 #4568 (#4569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support create ECS service with serviceRegistries configuration (#4564) Signed-off-by: khanhtc1202 * Support update service which contains serviceRegistries (#4567) Signed-off-by: khanhtc1202 * fix: ECS WaitService finish before task running (#4568) * fix: ECS WaitService finish before task running Signed-off-by: 徳田 真之介 * Update pkg/app/piped/platformprovider/ecs/client.go Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> Signed-off-by: 徳田 真之介 --------- Signed-off-by: 徳田 真之介 Co-authored-by: Khanh Tran <32532742+khanhtc1202@users.noreply.github.com> --------- Signed-off-by: khanhtc1202 Signed-off-by: 徳田 真之介 Co-authored-by: tokku5552 <69064290+tokku5552@users.noreply.github.com> --- pkg/app/piped/platformprovider/ecs/client.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/app/piped/platformprovider/ecs/client.go b/pkg/app/piped/platformprovider/ecs/client.go index 9e9a009414..6008c5832b 100644 --- a/pkg/app/piped/platformprovider/ecs/client.go +++ b/pkg/app/piped/platformprovider/ecs/client.go @@ -99,7 +99,6 @@ func (c *client) CreateService(ctx context.Context, service types.Service) (*typ PropagateTags: types.PropagateTagsService, Role: service.RoleArn, SchedulingStrategy: service.SchedulingStrategy, - ServiceRegistries: service.ServiceRegistries, Tags: service.Tags, } output, err := c.ecsClient.CreateService(ctx, input) @@ -110,8 +109,10 @@ func (c *client) CreateService(ctx context.Context, service types.Service) (*typ // Hack: Since we use EXTERNAL deployment controller, the below configurations are not allowed to be passed // in CreateService step, but it required in further step (CreateTaskSet step). We reassign those values // as part of service definition for that purpose. + // ref: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html output.Service.LaunchType = service.LaunchType output.Service.NetworkConfiguration = service.NetworkConfiguration + output.Service.ServiceRegistries = service.ServiceRegistries return output.Service, nil } @@ -134,8 +135,10 @@ func (c *client) UpdateService(ctx context.Context, service types.Service) (*typ // Hack: Since we use EXTERNAL deployment controller, the below configurations are not allowed to be passed // in UpdateService step, but it required in further step (CreateTaskSet step). We reassign those values // as part of service definition for that purpose. + // ref: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html output.Service.LaunchType = service.LaunchType output.Service.NetworkConfiguration = service.NetworkConfiguration + output.Service.ServiceRegistries = service.ServiceRegistries return output.Service, nil } @@ -204,6 +207,7 @@ func (c *client) CreateTaskSet(ctx context.Context, service types.Service, taskD // and you must specify a NetworkConfiguration when run a task with the task definition. NetworkConfiguration: service.NetworkConfiguration, LaunchType: service.LaunchType, + ServiceRegistries: service.ServiceRegistries, } if targetGroup != nil { input.LoadBalancers = []types.LoadBalancer{*targetGroup} @@ -248,7 +252,11 @@ func (c *client) WaitServiceStable(ctx context.Context, service types.Service) e Cluster: service.ClusterArn, Services: []string{*service.ServiceArn}, } - + // Wait before first checking the service state due to the logic checking service + // stable currently is based on `pendingCount`, which could always be `0` when + // the service deployment has started running. + // TODO: Wait until a new task is started instead of sleeping. + time.Sleep(30 * time.Second) retry := backoff.NewRetry(retryServiceStable, backoff.NewConstant(retryServiceStableInterval)) _, err := retry.Do(ctx, func() (interface{}, error) { output, err := c.ecsClient.DescribeServices(ctx, input)