Skip to content

Commit

Permalink
Cherry-pick #4564 #4567 #4568 (#4569)
Browse files Browse the repository at this point in the history
* Support create ECS service with serviceRegistries configuration (#4564)

Signed-off-by: khanhtc1202 <[email protected]>

* Support update service which contains serviceRegistries (#4567)

Signed-off-by: khanhtc1202 <[email protected]>

* fix: ECS WaitService finish before task running (#4568)

* fix: ECS WaitService finish before task running

Signed-off-by: 徳田 真之介 <[email protected]>

* Update pkg/app/piped/platformprovider/ecs/client.go

Co-authored-by: Khanh Tran <[email protected]>
Signed-off-by: 徳田 真之介 <[email protected]>

---------

Signed-off-by: 徳田 真之介 <[email protected]>
Co-authored-by: Khanh Tran <[email protected]>

---------

Signed-off-by: khanhtc1202 <[email protected]>
Signed-off-by: 徳田 真之介 <[email protected]>
Co-authored-by: tokku5552 <[email protected]>
  • Loading branch information
khanhtc1202 and tokku5552 authored Aug 25, 2023
1 parent 8480a0b commit 6b0499c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/app/piped/platformprovider/ecs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6b0499c

Please sign in to comment.