Skip to content

Commit 6b0499c

Browse files
Cherry-pick #4564 #4567 #4568 (#4569)
* 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]>
1 parent 8480a0b commit 6b0499c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (c *client) CreateService(ctx context.Context, service types.Service) (*typ
9999
PropagateTags: types.PropagateTagsService,
100100
Role: service.RoleArn,
101101
SchedulingStrategy: service.SchedulingStrategy,
102-
ServiceRegistries: service.ServiceRegistries,
103102
Tags: service.Tags,
104103
}
105104
output, err := c.ecsClient.CreateService(ctx, input)
@@ -110,8 +109,10 @@ func (c *client) CreateService(ctx context.Context, service types.Service) (*typ
110109
// Hack: Since we use EXTERNAL deployment controller, the below configurations are not allowed to be passed
111110
// in CreateService step, but it required in further step (CreateTaskSet step). We reassign those values
112111
// as part of service definition for that purpose.
112+
// ref: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html
113113
output.Service.LaunchType = service.LaunchType
114114
output.Service.NetworkConfiguration = service.NetworkConfiguration
115+
output.Service.ServiceRegistries = service.ServiceRegistries
115116

116117
return output.Service, nil
117118
}
@@ -134,8 +135,10 @@ func (c *client) UpdateService(ctx context.Context, service types.Service) (*typ
134135
// Hack: Since we use EXTERNAL deployment controller, the below configurations are not allowed to be passed
135136
// in UpdateService step, but it required in further step (CreateTaskSet step). We reassign those values
136137
// as part of service definition for that purpose.
138+
// ref: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_CreateService.html
137139
output.Service.LaunchType = service.LaunchType
138140
output.Service.NetworkConfiguration = service.NetworkConfiguration
141+
output.Service.ServiceRegistries = service.ServiceRegistries
139142

140143
return output.Service, nil
141144
}
@@ -204,6 +207,7 @@ func (c *client) CreateTaskSet(ctx context.Context, service types.Service, taskD
204207
// and you must specify a NetworkConfiguration when run a task with the task definition.
205208
NetworkConfiguration: service.NetworkConfiguration,
206209
LaunchType: service.LaunchType,
210+
ServiceRegistries: service.ServiceRegistries,
207211
}
208212
if targetGroup != nil {
209213
input.LoadBalancers = []types.LoadBalancer{*targetGroup}
@@ -248,7 +252,11 @@ func (c *client) WaitServiceStable(ctx context.Context, service types.Service) e
248252
Cluster: service.ClusterArn,
249253
Services: []string{*service.ServiceArn},
250254
}
251-
255+
// Wait before first checking the service state due to the logic checking service
256+
// stable currently is based on `pendingCount`, which could always be `0` when
257+
// the service deployment has started running.
258+
// TODO: Wait until a new task is started instead of sleeping.
259+
time.Sleep(30 * time.Second)
252260
retry := backoff.NewRetry(retryServiceStable, backoff.NewConstant(retryServiceStableInterval))
253261
_, err := retry.Do(ctx, func() (interface{}, error) {
254262
output, err := c.ecsClient.DescribeServices(ctx, input)

0 commit comments

Comments
 (0)