Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 588431e

Browse files
author
Kubernetes Submit Queue
authored
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](https://github.com/kubernetes/kubernetes/blob/93dc3763b0393b870855b2806b693a3224b039fa/pkg/controller/route/route_controller.go#L208) in the route controller to succeed and have the route removed if the route controller [feels responsible](https://github.com/kubernetes/kubernetes/blob/93dc3763b0393b870855b2806b693a3224b039fa/pkg/controller/route/route_controller.go#L206). ```release-note OpenStack cloudprovider: Ensure orphaned routes are removed. ```
2 parents 4e867c4 + 225151e commit 588431e

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_routes.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (r *Routes) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
5353
glog.V(4).Infof("ListRoutes(%v)", clusterName)
5454

5555
nodeNamesByAddr := make(map[string]types.NodeName)
56-
err := foreachServer(r.compute, servers.ListOpts{Status: "ACTIVE"}, func(srv *servers.Server) (bool, error) {
56+
err := foreachServer(r.compute, servers.ListOpts{}, func(srv *servers.Server) (bool, error) {
5757
addrs, err := nodeAddresses(srv)
5858
if err != nil {
5959
return false, err
@@ -77,15 +77,11 @@ func (r *Routes) ListRoutes(clusterName string) ([]*cloudprovider.Route, error)
7777

7878
var routes []*cloudprovider.Route
7979
for _, item := range router.Routes {
80-
nodeName, ok := nodeNamesByAddr[item.NextHop]
81-
if !ok {
82-
// Not one of our routes?
83-
glog.V(4).Infof("Skipping route with unknown nexthop %v", item.NextHop)
84-
continue
85-
}
80+
nodeName, foundNode := nodeNamesByAddr[item.NextHop]
8681
route := cloudprovider.Route{
8782
Name: item.DestinationCIDR,
88-
TargetNode: nodeName,
83+
TargetNode: nodeName, //empty if NextHop is unknown
84+
Blackhole: !foundNode,
8985
DestinationCIDR: item.DestinationCIDR,
9086
}
9187
routes = append(routes, &route)

0 commit comments

Comments
 (0)