mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 14:14:39 +00:00
Make route-controller list only relevant routes instead of all of them
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
@@ -46,7 +45,12 @@ func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, err
|
|||||||
listCall := gce.service.Routes.List(gce.projectID)
|
listCall := gce.service.Routes.List(gce.projectID)
|
||||||
|
|
||||||
prefix := truncateClusterName(clusterName)
|
prefix := truncateClusterName(clusterName)
|
||||||
listCall = listCall.Filter("name eq " + prefix + "-.*")
|
// Filter for routes starting with clustername AND belonging to the
|
||||||
|
// relevant gcp network AND having description = "k8s-node-route".
|
||||||
|
filter := "(name eq " + prefix + "-.*) "
|
||||||
|
filter = filter + "(network eq " + gce.networkURL + ") "
|
||||||
|
filter = filter + "(description eq " + k8sNodeRouteTag + ")"
|
||||||
|
listCall = listCall.Filter(filter)
|
||||||
if pageToken != "" {
|
if pageToken != "" {
|
||||||
listCall = listCall.PageToken(pageToken)
|
listCall = listCall.PageToken(pageToken)
|
||||||
}
|
}
|
||||||
@@ -58,18 +62,6 @@ func (gce *GCECloud) ListRoutes(clusterName string) ([]*cloudprovider.Route, err
|
|||||||
}
|
}
|
||||||
pageToken = res.NextPageToken
|
pageToken = res.NextPageToken
|
||||||
for _, r := range res.Items {
|
for _, r := range res.Items {
|
||||||
if r.Network != gce.networkURL {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Not managed if route description != "k8s-node-route"
|
|
||||||
if r.Description != k8sNodeRouteTag {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// Not managed if route name doesn't start with <clusterName>
|
|
||||||
if !strings.HasPrefix(r.Name, prefix) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
target := path.Base(r.NextHopInstance)
|
target := path.Base(r.NextHopInstance)
|
||||||
// TODO: Should we lastComponent(target) this?
|
// TODO: Should we lastComponent(target) this?
|
||||||
targetNodeName := types.NodeName(target) // NodeName == Instance Name on GCE
|
targetNodeName := types.NodeName(target) // NodeName == Instance Name on GCE
|
||||||
|
Reference in New Issue
Block a user