Skip to content

Commit

Permalink
Don't try to create routes for nodes w/o CIDRs assigned.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcullen committed Feb 11, 2016
1 parent 6bac4fd commit 918b0ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/controller/route/routecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ func (rc *RouteController) reconcile(nodes []api.Node, routes []*cloudprovider.R
routeMap[route.TargetInstance] = route
}
for _, node := range nodes {
// Skip if the node hasn't been assigned a CIDR yet.
if node.Spec.PodCIDR == "" {
continue
}
// Check if we have a route for this node w/ the correct CIDR.
r := routeMap[node.Name]
if r == nil || r.DestinationCIDR != node.Spec.PodCIDR {
Expand Down
11 changes: 11 additions & 0 deletions pkg/controller/route/routecontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ func TestReconcile(t *testing.T) {
{cluster + "-02", "node-2", "10.120.1.0/24"},
},
},
// 2 nodes, one node without CIDR assigned.
{
nodes: []api.Node{
{ObjectMeta: api.ObjectMeta{Name: "node-1", UID: "01"}, Spec: api.NodeSpec{PodCIDR: "10.120.0.0/24"}},
{ObjectMeta: api.ObjectMeta{Name: "node-2", UID: "02"}, Spec: api.NodeSpec{PodCIDR: ""}},
},
initialRoutes: []*cloudprovider.Route{},
expectedRoutes: []*cloudprovider.Route{
{cluster + "-01", "node-1", "10.120.0.0/24"},
},
},
}
for i, testCase := range testCases {
cloud := &fakecloud.FakeCloud{RouteMap: make(map[string]*fakecloud.FakeRoute)}
Expand Down

0 comments on commit 918b0ef

Please sign in to comment.