Skip to content

Commit

Permalink
Add logic to handle implicit route table associations to main route t…
Browse files Browse the repository at this point in the history
…able (#835)

* Add implicit association logic

* run go fmt

* remove unnecessary if statement

* add nil check
  • Loading branch information
erstaples authored and k8s-ci-robot committed Jun 17, 2019
1 parent 46d5f38 commit e3324c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/cloud/aws/services/ec2/routetables.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import (
)

const (
anyIPv4CidrBlock = "0.0.0.0/0"
anyIPv4CidrBlock = "0.0.0.0/0"
mainRouteTableInVPCKey = "main"
)

func (s *Service) reconcileRouteTables() error {
Expand Down Expand Up @@ -109,6 +110,9 @@ func (s *Service) describeVpcRouteTablesBySubnet() (map[string]*ec2.RouteTable,
res := make(map[string]*ec2.RouteTable)
for _, rt := range rts {
for _, as := range rt.Associations {
if as.Main != nil && *as.Main {
res[mainRouteTableInVPCKey] = rt
}
if as.SubnetId == nil {
continue
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/aws/services/ec2/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func (s *Service) describeVpcSubnets() (v1alpha1.Subnets, error) {

// ... or if it has an internet route
rt := routeTables[*ec2sn.SubnetId]
if rt == nil {
// If there is no explicit association, subnet defaults to main route table as implicit association
rt = routeTables[mainRouteTableInVPCKey]
}
if rt != nil {
spec.RouteTableID = rt.RouteTableId
for _, route := range rt.Routes {
Expand Down

0 comments on commit e3324c9

Please sign in to comment.