From b3869a27cb5890617521f35918c5888fb88ba8e8 Mon Sep 17 00:00:00 2001 From: zachaller Date: Thu, 7 Apr 2022 21:17:19 -0500 Subject: [PATCH 1/4] fix: this close issue #1963 by adding pagination to FindLoadBalancerByDNSName This adds pagination to the FindLoadBalancerByDNSName function this should allow argo rollouts to work with any number of loadbalancers. Signed-off-by: zachaller --- utils/aws/aws.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/utils/aws/aws.go b/utils/aws/aws.go index eba35e4f48..48d67ef597 100644 --- a/utils/aws/aws.go +++ b/utils/aws/aws.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/aws/aws-sdk-go-v2/aws" "strings" "github.com/argoproj/argo-rollouts/utils/defaults" @@ -128,13 +129,18 @@ func FakeNewClientFunc(elbClient ELBv2APIClient) func() (Client, error) { } func (c *ClientAdapter) FindLoadBalancerByDNSName(ctx context.Context, dnsName string) (*elbv2types.LoadBalancer, error) { - lbOutput, err := c.ELBV2.DescribeLoadBalancers(ctx, &elbv2.DescribeLoadBalancersInput{}) - if err != nil { - return nil, err - } - for _, lb := range lbOutput.LoadBalancers { - if lb.DNSName != nil && *lb.DNSName == dnsName { - return &lb, nil + paginator := elbv2.NewDescribeLoadBalancersPaginator(c.ELBV2, &elbv2.DescribeLoadBalancersInput{ + PageSize: aws.Int32(300), + }) + for paginator.HasMorePages() { + output, err := paginator.NextPage(ctx) + if err != nil { + return nil, err + } + for _, lb := range output.LoadBalancers { + if lb.DNSName != nil && *lb.DNSName == dnsName { + return &lb, nil + } } } return nil, nil From aba346145df1f46bf1ce7a2a91bf7c3955416a5d Mon Sep 17 00:00:00 2001 From: zachaller Date: Fri, 8 Apr 2022 14:46:53 -0500 Subject: [PATCH 2/4] fix deps Signed-off-by: zachaller --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 0ac3bf0f6d..ce8e3e1388 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/antonmedv/expr v1.9.0 github.com/argoproj/notifications-engine v0.3.1-0.20220129012210-32519f8f68ec github.com/argoproj/pkg v0.9.0 + github.com/aws/aws-sdk-go-v2 v1.13.0 github.com/aws/aws-sdk-go-v2/config v1.13.1 github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.15.0 github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.16.0 @@ -66,7 +67,6 @@ require ( github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/RocketChat/Rocket.Chat.Go.SDK v0.0.0-20210112200207-10ab4d695d60 // indirect - github.com/aws/aws-sdk-go-v2 v1.13.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.10.0 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.4 // indirect From e51dc00766c3c18fe7d61ffd6cb62421740ecea7 Mon Sep 17 00:00:00 2001 From: zachaller Date: Fri, 8 Apr 2022 14:50:54 -0500 Subject: [PATCH 3/4] pre commit check Signed-off-by: zachaller --- utils/aws/aws.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/aws/aws.go b/utils/aws/aws.go index 48d67ef597..bf78908a8e 100644 --- a/utils/aws/aws.go +++ b/utils/aws/aws.go @@ -4,9 +4,10 @@ import ( "context" "encoding/json" "fmt" - "github.com/aws/aws-sdk-go-v2/aws" "strings" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/argoproj/argo-rollouts/utils/defaults" "github.com/aws/aws-sdk-go-v2/config" elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" From 576f18dd2808a7ae58d340260aa695e3ccf1b1f1 Mon Sep 17 00:00:00 2001 From: zachaller Date: Mon, 11 Apr 2022 13:26:41 -0500 Subject: [PATCH 4/4] Use default package Signed-off-by: zachaller --- utils/aws/aws.go | 2 +- utils/defaults/defaults.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/aws/aws.go b/utils/aws/aws.go index bf78908a8e..501e17b3ac 100644 --- a/utils/aws/aws.go +++ b/utils/aws/aws.go @@ -131,7 +131,7 @@ func FakeNewClientFunc(elbClient ELBv2APIClient) func() (Client, error) { func (c *ClientAdapter) FindLoadBalancerByDNSName(ctx context.Context, dnsName string) (*elbv2types.LoadBalancer, error) { paginator := elbv2.NewDescribeLoadBalancersPaginator(c.ELBV2, &elbv2.DescribeLoadBalancersInput{ - PageSize: aws.Int32(300), + PageSize: aws.Int32(defaults.DefaultAwsLoadBalancerPageSize), }) for paginator.HasMorePages() { output, err := paginator.NextPage(ctx) diff --git a/utils/defaults/defaults.go b/utils/defaults/defaults.go index 8a9a000675..5570f65481 100644 --- a/utils/defaults/defaults.go +++ b/utils/defaults/defaults.go @@ -40,6 +40,8 @@ const ( DefaultQPS float32 = 40.0 // DefaultBurst is the default value for Burst for client side throttling to the K8s API server DefaultBurst int = 80 + // DefaultAwsLoadBalancerPageSize is the default page size used when calling aws to get load balancers by DNS name + DefaultAwsLoadBalancerPageSize = int32(300) ) const (