aws / aws-sdk-go

AWS SDK for the Go programming language (In Maintenance Mode, End-of-Life on 07/31/2025). The AWS SDK for Go v2 is available here: https://github.com/aws/aws-sdk-go-v2
http://aws.amazon.com/sdk-for-go/
Apache License 2.0
8.65k stars 2.07k forks source link

Unable to list all Load Balancers using Empty List of ARNs are parameter #3152

Closed BrunoMCBraga closed 4 years ago

BrunoMCBraga commented 4 years ago

Please fill out the sections below to help us address your issue.

Version of AWS SDK for Go?

v1.29.3

Version of Go (go version)?

go version go1.13.7 darwin/amd64

What issue did you see?

Following up on https://github.com/aws/aws-sdk-go/issues/3141 i managed to delete all network resources. However, as soon as i make a deployment on the containers, the LoadBalancers and some other network interfaces are attached so i need to clean these. I tried to detach and delete network interfaces but i need to delete LoadBalancers first. It seems that DescribeLoadBalancers can help me list all of them but when i call it without any ARNs, nothing is returned (i.e. len(DescribeLoadBalancersOutput.LoadBalancers) == 0). My code:

func describeLoadBalancersStub() (*elbv2.DescribeLoadBalancersOutput, error) {

    describeLoadBalancersInputObject := &elbv2.DescribeLoadBalancersInput{}

    return elbInstance.DescribeLoadBalancers(describeLoadBalancersInputObject)

}

Steps to reproduce

If you have an runnable example, please include it.

Any help would be much appreciated.

diehlaws commented 4 years ago

Hey @BrunoMCBraga, thanks for reaching out to us. Unfortunately I'm not able to reproduce the behavior you're seeing - calling DescribeLoadBalancers with an empty DescribeLoadBalancersInput struct returns the appropriate load balancers for the region in which I'm initializing my service client. Can you provide debug logs for a request that exhibits this behavior so we can see what the HTTP request and response to/from the ELB service look like on your end? This can be set in the config struct passed to your service client's session with LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody).

BrunoMCBraga commented 4 years ago

Will do and let you know :)

BrunoMCBraga commented 4 years ago
2020/02/21 11:21:36 DEBUG: Request elasticloadbalancing/DescribeLoadBalancers Details:
---[ REQUEST POST-SIGN ]-----------------------------
POST / HTTP/1.1
Host: elasticloadbalancing.us-east-1.amazonaws.com
User-Agent: aws-sdk-go/1.29.0 (go1.13.7; darwin; amd64)
Content-Length: 47
Authorization: AWS4-HMAC-SHA256 Credential=AKIA6BSFWKLAXWN4JYKE/20200221/us-east-1/elasticloadbalancing/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date, Signature=1b175f019ce3a674eb4f035315777aa1540ba2141ce644af4dbe92c76bd7b0c5
Content-Type: application/x-www-form-urlencoded; charset=utf-8
X-Amz-Date: 20200221T102136Z
Accept-Encoding: gzip

Action=DescribeLoadBalancers&Version=2015-12-01
-----------------------------------------------------
2020/02/21 11:21:37 DEBUG: Response elasticloadbalancing/DescribeLoadBalancers Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 200 OK
Content-Length: 324
Content-Type: text/xml
Date: Fri, 21 Feb 2020 10:21:37 GMT
X-Amzn-Requestid: 53b3aa30-6c4d-4b91-943f-d08b5a0825a6

-----------------------------------------------------
2020/02/21 11:21:37 <DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2015-12-01/">
  <DescribeLoadBalancersResult>
    <LoadBalancers/>
  </DescribeLoadBalancersResult>
  <ResponseMetadata>
    <RequestId>53b3aa30-6c4d-4b91-943f-d08b5a0825a6</RequestId>
  </ResponseMetadata>
</DescribeLoadBalancersResponse>

Some pictures:

Screenshot 2020-02-21 at 11 23 39 Screenshot 2020-02-21 at 11 24 09 Screenshot 2020-02-21 at 11 24 19

And how i initialize ELB:

elbSession := elbv2.New(awsSession, aws.NewConfig().WithLogLevel(aws.LogLevelType(aws.LogDebugWithHTTPBody)).WithRegion(*regionConfig))

where regionConfig is:"us-east-1".

Really don't know what is going on here :(

BrunoMCBraga commented 4 years ago

Not sure if worth mentioning but these load balancers are spawned as a result of launching Services to expose the pods. I am using https://github.com/kubernetes/client-go (i.e. i am not using any CreateLoadBalancer method like https://docs.aws.amazon.com/sdk-for-go/api/service/elb/#ELB.CreateLoadBalancer)

Should not make a difference though since it all works well. i can spawn the containers, expose the services and access them but when trying to clean up all the things it fails (i.e. i cannot delete/detach network interfaces because there are load balancers i need to delete first).

BrunoMCBraga commented 4 years ago

So i used elb instead of elbv2. The former methods showed the loadbalancers the latter did not. Could this be some issues with a new version of elbv2? Should i use elbv2?

Thanks

diehlaws commented 4 years ago

Apologies for the delay in response on this @BrunoMCBraga. The lack of a response body in the debug output provided suggests this is likely a behavior related to differences between the API versions used for the elb (2012-06-01) and elbv2 (2015-12-01) packages.

I suspect in your case the load balancers were created with ELB's older API version. Issuing a CreateLoadBalancer call in an otherwise empty region using the elb package results in the behavior you describe: elbv2's DescribeLoadBalancers call returns an empty response, whereas elb's DescribeLoadBalancers call returns the load balancer omitted by elbv2.

binduc23 commented 2 years ago

the is still persist for me in the elb and elbv2

result, := client.DescribeLoadBalancers(&elb.DescribeLoadBalancersInput{}) or result, := client.DescribeLoadBalancers(&elbv2.DescribeLoadBalancersInput{})

binduc23 commented 2 years ago

@BrunoMCBraga @diehlaws could you please help on this regard

binduc23 commented 2 years ago

https://github.com/aws/aws-sdk-go/issues/4374