Skip to content

Commit

Permalink
awstagdeprovision: Tag 20 load balancers (max) per request
Browse files Browse the repository at this point in the history
The previous implementation silently ignored errors returned by
lbToAWSObjects.  After inserting some debugging logging and running
against our CI account, I saw:

  DEBU[2018-09-28T21:54:47-07:00] failed to convert to lbObjects: Error fetching tags for load balancers: ValidationError: 1 validation error detected: Value '[ci-op-d7qwcq8r-1d3f3-con, ci-op-d7qwcq8r-1d3f3-ext, ci-op-d7qwcq8r-1d3f3-int, ci-op-274cpi9w-1d3f3-con, ci-op-274cpi9w-1d3f3-ext, ci-op-274cpi9w-1d3f3-int, ci-op-i01107d8-1d3f3-con, ci-op-i01107d8-1d3f3-ext, ci-op-i01107d8-1d3f3-int, ci-op-5c88gcn3-1d3f3-int, ci-op-5c88gcn3-1d3f3-con, ci-op-5c88gcn3-1d3f3-ext, ci-op-pp79f299-1d3f3-con, ci-op-pp79f299-1d3f3-ext, ci-op-pp79f299-1d3f3-int, ci-op-dnflccjn-1d3f3-con, ci-op-dnflccjn-1d3f3-ext, ci-op-dnflccjn-1d3f3-int, ci-op-k94dmy6q-1d3f3-ext, ci-op-k94dmy6q-1d3f3-con, ci-op-k94dmy6q-1d3f3-int, ci-op-px7qd18y-1d3f3-con, ci-op-px7qd18y-1d3f3-ext, ci-op-px7qd18y-1d3f3-int, ci-op-8bx1yb6n-1d3f3-int, ci-op-8bx1yb6n-1d3f3-ext, ci-op-8bx1yb6n-1d3f3-con, ci-op-ms0zyi8r-1d3f3-ext, ci-op-ms0zyi8r-1d3f3-int, ci-op-ms0zyi8r-1d3f3-con, ci-op-w7w2z53b-1d3f3-ext, ci-op-w7w2z53b-1d3f3-con, ci-op-w7w2z53b-1d3f3-int, ci-op-hd2bkkcr-1d3f3-int, ci-op-hd2bkkcr-1d3f3-ext, ci-op-hd2bkkcr-1d3f3-con, ci-op-9jv0t7ib-1d3f3-int, ci-op-9jv0t7ib-1d3f3-con, ci-op-9jv0t7ib-1d3f3-ext, ci-op-kr1g9hr3-1d3f3-int, ci-op-kr1g9hr3-1d3f3-ext, ci-op-kr1g9hr3-1d3f3-con, ci-op-k5bn7vbb-1d3f3-con, ci-op-k5bn7vbb-1d3f3-int, ci-op-k5bn7vbb-1d3f3-ext, ci-op-p6qisqvk-1d3f3-ext, ci-op-p6qisqvk-1d3f3-int, ci-op-y5zj1kvd-1d3f3-int, ci-op-y5zj1kvd-1d3f3-con, ci-op-p6qisqvk-1d3f3-con, ci-op-y5zj1kvd-1d3f3-ext]' at 'loadBalancerNames' failed to satisfy constraint: Member must have length less than or equal to 20

With this commit, I split the load balancers up into groups of 20
(max) when building the list of tagged objects.  I also log any errors
that crop up.

Along these same lines, DescribeLoadBalancers itself is paginated, but
the default page size (and also the maximum page size) is 400 [1].  So
I'm punting on that for now.

[1]: https://docs.aws.amazon.com/sdk-for-go/api/service/elb/#DescribeLoadBalancersInput
  • Loading branch information
wking committed Sep 29, 2018
1 parent 41846e8 commit e49201c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions contrib/pkg/awstagdeprovision/awstagdeprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,18 @@ func deleteLBs(awsSession *session.Session, filters awsFilter, clusterName strin
return false, nil
}

lbObjects, err := lbToAWSObjects(results.LoadBalancerDescriptions, elbClient)
if err != nil {
return false, nil
lbObjects := []awsObjectWithTags{}
for i := 0; i < len(results.LoadBalancerDescriptions); i += 20 {
j := i + 20
if j > len(results.LoadBalancerDescriptions) {
j = len(results.LoadBalancerDescriptions)
}
new, err := lbToAWSObjects(results.LoadBalancerDescriptions[i:j], elbClient)
if err != nil {
logger.Errorf("error converting load balancers to internal AWS objects: %v", err)
return false, nil
}
lbObjects = append(lbObjects, new...)
}

filteredResults := filterObjects(lbObjects, filters)
Expand Down

0 comments on commit e49201c

Please sign in to comment.