Merge pull request #56258 from databus23/patch-1

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

openstack: remove orphaned routes from terminated instances

**What this PR does / why we need it**:
At the moment the openstack cloudprovider only returns routes where the `NextHop` address points to an existing openstack instance. This is a problem when an instance is terminated before the corresponding node is removed from k8s. The existing route is not returned by the cloudprovider anymore and therefore never considered for deletion by the route controller. When the route's `DestinationCIDR` is reassigned to a new node the router ends up with two routes pointing to a different `NextHop` leading to broken networking.

This PR removes skipping routes pointing to unknown next hops when listing routes. This should cause [this conditional](93dc3763b0/pkg/controller/route/route_controller.go (L208)) in the route controller to succeed and have the route removed if the route controller [feels responsible](93dc3763b0/pkg/controller/route/route_controller.go (L206)).

```release-note
OpenStack cloudprovider: Ensure orphaned routes are removed.
```
pull/6/head
Kubernetes Submit Queue 2018-01-18 06:53:15 -08:00 committed by GitHub
commit 40b0c5516a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 8 deletions

View File

@ -53,7 +53,7 @@ func (r *Routes) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
glog.V(4).Infof("ListRoutes(%v)", clusterName)
nodeNamesByAddr := make(map[string]types.NodeName)
err := foreachServer(r.compute, servers.ListOpts{Status: "ACTIVE"}, func(srv *servers.Server) (bool, error) {
err := foreachServer(r.compute, servers.ListOpts{}, func(srv *servers.Server) (bool, error) {
addrs, err := nodeAddresses(srv)
if err != nil {
return false, err
@ -77,15 +77,11 @@ func (r *Routes) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
var routes []*cloudprovider.Route
for _, item := range router.Routes {
nodeName, ok := nodeNamesByAddr[item.NextHop]
if !ok {
// Not one of our routes?
glog.V(4).Infof("Skipping route with unknown nexthop %v", item.NextHop)
continue
}
nodeName, foundNode := nodeNamesByAddr[item.NextHop]
route := cloudprovider.Route{
Name: item.DestinationCIDR,
TargetNode: nodeName,
TargetNode: nodeName, //empty if NextHop is unknown
Blackhole: !foundNode,
DestinationCIDR: item.DestinationCIDR,
}
routes = append(routes, &route)