Skip to content

Commit

Permalink
Fix fetchAccount with more than 10 services
Browse files Browse the repository at this point in the history
describeServices only supports up to 10 services, so we need to split
the request in chunks of 10
  • Loading branch information
graphman65 authored and hamstah committed Jun 29, 2021
1 parent c205bd1 commit 6c9d238
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions ecs/dashboard/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import (
log "github.com/sirupsen/logrus"
)

const (
serviceNameChunkSize = 10
)

func fetchAccount(account Account) (*AccountState, error) {
logger := log.WithFields(log.Fields{
"account": account.AccountName,
Expand Down Expand Up @@ -50,16 +54,24 @@ func fetchAccount(account Account) (*AccountState, error) {
continue
}

if len(serviceNames) == 0 {
serviceCount := len(serviceNames)
if serviceCount == 0 {
continue
}

newServices, err := describeServices(svc, cluster.ClusterName, serviceNames)
if err != nil {
logger.Error(err)
continue
for i := 0; i < serviceCount; i += serviceNameChunkSize {
maxIndex := i + serviceNameChunkSize
if maxIndex > serviceCount {
maxIndex = serviceCount
}

newServices, err := describeServices(svc, cluster.ClusterName, serviceNames[i:maxIndex])
if err != nil {
logger.Error(err)
continue
}
services = append(services, newServices...)
}
services = append(services, newServices...)
}

for _, service := range services {
Expand Down

0 comments on commit 6c9d238

Please sign in to comment.