Skip to content

Commit

Permalink
Merge pull request #3 from rifelpet/dep-update
Browse files Browse the repository at this point in the history
Fix AWS IMDS discovery of ipv6 and ipv4 addresses
  • Loading branch information
k8s-ci-robot authored Aug 3, 2024
2 parents aa0cc22 + 978b3f5 commit f1ea649
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pkg/volumes/aws/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,14 @@ func NewAWSVolumes(clusterName string, volumeTags []string, nameTag string) (*AW
o.Region = region
})
ipv6Resp, err := a.imds.GetMetadata(ctx, &imds.GetMetadataInput{Path: "ipv6"})
if err != nil {
return nil, fmt.Errorf("error querying ec2 metadata service (for ipv6): %v", err)
}
ipv6, err := io.ReadAll(ipv6Resp.Content)
if err != nil {
return nil, fmt.Errorf("error reading ec2 metadata service response (for ipv6): %v", err)
}
a.localIP = string(ipv6)

// If we have an IPv6 address, return
if err == nil {
ipv6, err := io.ReadAll(ipv6Resp.Content)
if err != nil {
return nil, fmt.Errorf("error reading ec2 metadata service response (for ipv6): %v", err)
}
a.localIP = string(ipv6)

return a, nil
}
var awsErr *awshttp.ResponseError
Expand Down

0 comments on commit f1ea649

Please sign in to comment.