Skip to content

Commit

Permalink
fix: fetch more than 10 servics (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
keidarcy committed May 22, 2024
1 parent 51a5998 commit 3c5001d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/api/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (store *Store) ListClusters() ([]types.Cluster, error) {
Include: include,
})
if err != nil {
slog.Warn("failed to run aws api to describe clusters", "error", err)
slog.Warn("failed to run aws api to describe clusters", "i times loop", i, "error", err)
return err
}

Expand Down
8 changes: 5 additions & 3 deletions internal/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ func (store *Store) ListServices(clusterName *string) ([]types.Service, error) {
// You may specify up to 100 services to describe.
// If there are > 100 services in the cluster, loop and slice by 100
// to describe them in batches of <= 100.
batchSize := 100
limit := int32(batchSize)
limit := int32(100)
params := &ecs.ListServicesInput{
Cluster: clusterName,
MaxResults: &limit,
Expand Down Expand Up @@ -51,6 +50,9 @@ func (store *Store) ListServices(clusterName *string) ([]types.Service, error) {
}
}

// DescribeService api limit is 10
// InvalidParameterException: service names can have at most 10 items
batchSize := 10
serviceCount := len(serviceARNs)
loopCount := serviceCount / batchSize

Expand Down Expand Up @@ -79,7 +81,7 @@ func (store *Store) ListServices(clusterName *string) ([]types.Service, error) {
},
})
if err != nil {
slog.Warn("failed to run aws api to describe services in i:%d times loop", "error", i, err)
slog.Warn("failed to run aws api to describe services", "i times loop", i, "error", err)
return err
}

Expand Down

0 comments on commit 3c5001d

Please sign in to comment.