Skip to content

Commit

Permalink
Fix handling limit of certificates per ALB (#184)
Browse files Browse the repository at this point in the history
* Remove getter and setters for easier testing

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>

* Fix handling limit of certificates per ALB

This fixes a couple of bugs related to exceeding the maximum number of
certificates per ALB.

It limits the max size to 24 instead of 25. This is done because we need
to duplicate the default certificate to work around a CloudFormation bug
(#162) and therefore need one extra space for this limiting the maximum
unique certificates per ALB to 24 instead of the AWS limit of 25.

It also fixes a bug in `AddIngress` which could potentially add some of
the certificates for a single ingress to a stack and the rest to
another stack resulting in an undesired state.

Thirdly it adds rollback complete states to `IsComplete()` to
automatically attempt to update stacks that are in a rollback complete
state.

Fix #176, #175

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>

* Vendor with dep

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>

* Check for nil stack

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>

* Sync load balancer state with stack state

Signed-off-by: Mikkel Oscar Lyderik Larsen <[email protected]>
  • Loading branch information
mikkeloscar authored Jul 9, 2018
1 parent cb90c31 commit 230c6d9
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 341 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ matrix:
- go: tip

before_install:
- go get github.com/Masterminds/glide
- curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
- go get github.com/mattn/goveralls
- go get github.com/alecthomas/gometalinter

install:
- glide install --strip-vendor
- dep ensure -v -vendor-only
- gometalinter --install

script:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# builder image
FROM golang as builder

RUN go get github.com/Masterminds/glide
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
WORKDIR /go/src/github.com/zalando-incubator/kube-ingress-aws-controller
COPY . .
RUN glide install --strip-vendor
RUN dep ensure -v -vendor-only
RUN make test
RUN make build.linux

Expand Down
178 changes: 178 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/aws/aws-sdk-go"
version = "~1.13.6"

[[constraint]]
name = "github.com/google/uuid"
version = "0.2.0"

[[constraint]]
name = "github.com/linki/instrumented_http"
version = "0.2.0"

[[constraint]]
branch = "master"
name = "github.com/mweagle/go-cloudformation"

[[constraint]]
name = "github.com/pkg/errors"
version = "0.8.0"

[[constraint]]
name = "github.com/prometheus/client_golang"
version = "0.8.0"

[[constraint]]
name = "github.com/stretchr/testify"
version = "~1.2.2"

[prune]
go-tests = true
unused-packages = true
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ resource anymore, it deletes all the previously created resources.

This project provides a [`Makefile`](https://github.com/zalando-incubator/kube-ingress-aws-controller/blob/master/Makefile)
that you can use to build either a binary or a Docker image. You have
to have [glide installed](https://github.com/Masterminds/glide) and do
`glide install`, before building.
to have [dep installed](https://github.com/golang/dep#installation) and do
`dep ensure -vendor-only`, before building.

### Building a Binary

Expand Down
12 changes: 8 additions & 4 deletions aws/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ const (
DefaultStackTTL = 5 * time.Minute
DefaultIdleConnectionTimeout = 1 * time.Minute
DefaultControllerID = "kube-ingress-aws-controller"
DefaultMaxCertsPerALB = 25
// DefaultMaxCertsPerALB defines the maximum number of certificates per
// ALB. AWS limit is 25 but one space is needed to work around
// CloudFormation bug:
// https://github.com/zalando-incubator/kube-ingress-aws-controller/pull/162
DefaultMaxCertsPerALB = 24

nameTag = "Name"

Expand Down Expand Up @@ -317,7 +321,7 @@ func (a *Adapter) FindManagedStacks() ([]*Stack, error) {
func (a *Adapter) UpdateTargetGroupsAndAutoScalingGroups(stacks []*Stack) {
targetGroupARNs := make([]string, len(stacks))
for i, stack := range stacks {
targetGroupARNs[i] = stack.targetGroupARN
targetGroupARNs[i] = stack.TargetGroupARN
}

// don't do anything if there are no target groups
Expand Down Expand Up @@ -425,12 +429,12 @@ func (a *Adapter) GetStack(stackID string) (*Stack, error) {
// DeleteStack deletes the CloudFormation stack with the given name
func (a *Adapter) DeleteStack(stack *Stack) error {
for _, asg := range a.autoScalingGroups {
if err := detachTargetGroupsFromAutoScalingGroup(a.autoscaling, []string{stack.TargetGroupARN()}, asg.name); err != nil {
if err := detachTargetGroupsFromAutoScalingGroup(a.autoscaling, []string{stack.TargetGroupARN}, asg.name); err != nil {
return fmt.Errorf("DeleteStack failed to detach: %v", err)
}
}

return deleteStack(a.cloudformation, stack.Name())
return deleteStack(a.cloudformation, stack.Name)
}

func buildManifest(awsAdapter *Adapter) (*manifest, error) {
Expand Down
Loading

0 comments on commit 230c6d9

Please sign in to comment.