Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable to fetch ECS taskset tags #4605

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions pkg/app/piped/platformprovider/ecs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
if taskDefinition.TaskDefinitionArn == nil {
return nil, fmt.Errorf("failed to create task set of task family %s: no task definition provided", *taskDefinition.Family)
}

input := &ecs.CreateTaskSetInput{
Cluster: service.ClusterArn,
Service: service.ServiceArn,
Expand Down Expand Up @@ -266,16 +267,38 @@
return nil, fmt.Errorf("failed to get task sets of service %s: services empty", *service.ServiceName)
}
svc := output.Services[0]
taskSets := make([]*types.TaskSet, 0, len(svc.TaskSets))
activeTaskSetArns := make([]string, 0, len(svc.TaskSets))

Check warning on line 270 in pkg/app/piped/platformprovider/ecs/client.go

View check run for this annotation

Codecov / codecov/patch

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

Added line #L270 was not covered by tests
for i := range svc.TaskSets {
if aws.ToString(svc.TaskSets[i].Status) == "DRAINING" {
continue
}
if !IsPipeCDManagedTaskSet(&svc.TaskSets[i]) {
activeTaskSetArns = append(activeTaskSetArns, *svc.TaskSets[i].TaskSetArn)

Check warning on line 275 in pkg/app/piped/platformprovider/ecs/client.go

View check run for this annotation

Codecov / codecov/patch

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

Added line #L275 was not covered by tests
}

if len(activeTaskSetArns) == 0 {
return nil, fmt.Errorf("failed to get task sets of service %s: services empty", *service.ServiceName)
}

Check warning on line 280 in pkg/app/piped/platformprovider/ecs/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/ecs/client.go#L278-L280

Added lines #L278 - L280 were not covered by tests

tsInput := &ecs.DescribeTaskSetsInput{
Cluster: service.ClusterArn,
Service: service.ServiceArn,
TaskSets: activeTaskSetArns,
Include: []types.TaskSetField{
types.TaskSetFieldTags,
},
}
tsOutput, err := c.ecsClient.DescribeTaskSets(ctx, tsInput)
if err != nil {
return nil, fmt.Errorf("failed to get task sets of service %s: %w", *service.ServiceName, err)
}
taskSets := make([]*types.TaskSet, 0, len(tsOutput.TaskSets))
for i := range tsOutput.TaskSets {
if !IsPipeCDManagedTaskSet(&tsOutput.TaskSets[i]) {

Check warning on line 296 in pkg/app/piped/platformprovider/ecs/client.go

View check run for this annotation

Codecov / codecov/patch

pkg/app/piped/platformprovider/ecs/client.go#L282-L296

Added lines #L282 - L296 were not covered by tests
continue
}
taskSets = append(taskSets, &svc.TaskSets[i])
taskSets = append(taskSets, &tsOutput.TaskSets[i])

Check warning on line 299 in pkg/app/piped/platformprovider/ecs/client.go

View check run for this annotation

Codecov / codecov/patch

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

Added line #L299 was not covered by tests
}

return taskSets, nil
}

Expand Down
Loading