Skip to content

Commit

Permalink
Merge branch 'master' into listener-nil-pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
bigkraig committed Sep 13, 2018
2 parents a774706 + df5bc6a commit e7e8ba3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 51 deletions.
2 changes: 1 addition & 1 deletion alb-ingress-controller-helm/Chart.yaml
Expand Up @@ -14,4 +14,4 @@ maintainers:
name: alb-ingress-controller-helm
sources:
- https://github.com/kubernetes-sigs/aws-alb-ingress-controller
version: 0.1.1
version: 0.1.2
4 changes: 2 additions & 2 deletions alb-ingress-controller-helm/templates/deployment.yaml
Expand Up @@ -64,15 +64,15 @@ spec:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 30
initialDelaySeconds: {{ .Values.readinessProbeInitialDelay }}
periodSeconds: {{ .Values.readinessProbeInterval }}
timeoutSeconds: {{ .Values.readinessProbeTimeout }}
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: {{ add 30 .Values.readinessProbeTimeout }}
initialDelaySeconds: {{ add .Values.livenessProbeInitialDelay .Values.readinessProbeInitialDelay }}
periodSeconds: 60
{{- if .Values.resources }}
resources:
Expand Down
6 changes: 6 additions & 0 deletions alb-ingress-controller-helm/values.yaml
Expand Up @@ -47,6 +47,12 @@ readinessProbeInterval: 10
# How long to wait before timeout (in seconds) when checking controller readiness
readinessProbeTimeout: 1

# How long to wait (in seconds) before checking the readiness probe
readinessProbeInitialDelay : 30

# How long to wait (in seconds) before checking the liveness probe
livenessProbeInitialDelay : 30

resources:
{}
# limits:
Expand Down
35 changes: 9 additions & 26 deletions internal/aws/albelbv2/elbv2.go
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/aws/aws-sdk-go/service/elbv2/elbv2iface"
Expand Down Expand Up @@ -346,24 +345,16 @@ func (e *ELBV2) ClusterLoadBalancers() ([]*elbv2.LoadBalancer, error) {
return nil, fmt.Errorf("Failed to get AWS tags. Error: %s", err.Error())
}

p := request.Pagination{
NewRequest: func() (*request.Request, error) {
req, _ := e.DescribeLoadBalancersRequest(&elbv2.DescribeLoadBalancersInput{})
return req, nil
},
}

for p.Next() {
page := p.Page().(*elbv2.DescribeLoadBalancersOutput)

err = e.DescribeLoadBalancersPages(&elbv2.DescribeLoadBalancersInput{}, func(page *elbv2.DescribeLoadBalancersOutput, _ bool) bool {
for _, loadBalancer := range page.LoadBalancers {
if _, ok := rgt.LoadBalancers[*loadBalancer.LoadBalancerArn]; ok {
loadbalancers = append(loadbalancers, loadBalancer)
}
}
}
return true
})

return loadbalancers, p.Err()
return loadbalancers, err
}

// ClusterTargetGroups fetches all target groups that are part of the cluster.
Expand All @@ -384,29 +375,21 @@ func (e *ELBV2) ClusterTargetGroups() (map[string][]*elbv2.TargetGroup, error) {
return nil, fmt.Errorf("Failed to get AWS tags. Error: %s", err.Error())
}

p := request.Pagination{
NewRequest: func() (*request.Request, error) {
req, _ := e.DescribeTargetGroupsRequest(&elbv2.DescribeTargetGroupsInput{})
return req, nil
},
}

for p.Next() {
page := p.Page().(*elbv2.DescribeTargetGroupsOutput)

err = e.DescribeTargetGroupsPages(&elbv2.DescribeTargetGroupsInput{}, func(page *elbv2.DescribeTargetGroupsOutput, _ bool) bool {
for _, targetGroup := range page.TargetGroups {
for _, lbarn := range targetGroup.LoadBalancerArns {
if _, ok := rgt.LoadBalancers[*lbarn]; ok {
output[*lbarn] = append(output[*lbarn], targetGroup)
}
}
}
}
return true
})

if p.Err() == nil {
if err == nil {
albcache.Set(cacheName, key, output, time.Minute*1)
}
return output, p.Err()
return output, err
}

// DescribeLoadBalancerAttributesFiltered returns the non-default load balancer attributes
Expand Down
35 changes: 13 additions & 22 deletions internal/aws/albrgt/rgt.go
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/aws/aws-sdk-go/aws"

"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"
Expand Down Expand Up @@ -73,42 +72,42 @@ func (r *RGT) GetClusterResources() (*Resources, error) {
}

paramSet := []*resourcegroupstaggingapi.GetResourcesInput{
&resourcegroupstaggingapi.GetResourcesInput{
{
ResourceTypeFilters: []*string{
aws.String("ec2"),
},
TagFilters: []*resourcegroupstaggingapi.TagFilter{
&resourcegroupstaggingapi.TagFilter{
{
Key: aws.String("kubernetes.io/role/internal-elb"),
Values: []*string{aws.String(""), aws.String("1")},
},
&resourcegroupstaggingapi.TagFilter{
{
Key: aws.String("kubernetes.io/cluster/" + r.clusterName),
Values: []*string{aws.String("owned"), aws.String("shared")},
},
},
},
&resourcegroupstaggingapi.GetResourcesInput{
{
ResourceTypeFilters: []*string{
aws.String("ec2"),
},
TagFilters: []*resourcegroupstaggingapi.TagFilter{
&resourcegroupstaggingapi.TagFilter{
{
Key: aws.String("kubernetes.io/role/elb"),
Values: []*string{aws.String(""), aws.String("1")},
},
&resourcegroupstaggingapi.TagFilter{
{
Key: aws.String("kubernetes.io/cluster/" + r.clusterName),
Values: []*string{aws.String("owned"), aws.String("shared")},
},
},
},
&resourcegroupstaggingapi.GetResourcesInput{
{
ResourceTypeFilters: []*string{
aws.String("elasticloadbalancing"),
},
TagFilters: []*resourcegroupstaggingapi.TagFilter{
&resourcegroupstaggingapi.TagFilter{
{
Key: aws.String("kubernetes.io/cluster/" + r.clusterName),
Values: []*string{aws.String("owned"), aws.String("shared")},
},
Expand All @@ -117,16 +116,7 @@ func (r *RGT) GetClusterResources() (*Resources, error) {
}

for _, param := range paramSet {
p := request.Pagination{
EndPageOnSameToken: true,
NewRequest: func() (*request.Request, error) {
req, _ := r.GetResourcesRequest(param)
return req, nil
},
}

for p.Next() {
page := p.Page().(*resourcegroupstaggingapi.GetResourcesOutput)
err := r.GetResourcesPages(param, func(page *resourcegroupstaggingapi.GetResourcesOutput, lastPage bool) bool {
for _, rtm := range page.ResourceTagMappingList {
switch {
case strings.Contains(*rtm.ResourceARN, ":loadbalancer/app/"):
Expand All @@ -141,9 +131,10 @@ func (r *RGT) GetClusterResources() (*Resources, error) {
resources.Subnets[*rtm.ResourceARN] = rgtTagAsEC2Tag(rtm.Tags)
}
}
}
if p.Err() != nil {
return nil, p.Err()
return true
})
if err != nil {
return nil, err
}
}

Expand Down

0 comments on commit e7e8ba3

Please sign in to comment.