Skip to content

Commit

Permalink
fix: new ovn-ic static route method adapted due to old ovn version (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 authored Jul 20, 2022
1 parent eb412c9 commit 417176e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/controller/ovn-ic.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ func (c *Controller) SynRouteToPolicy() {
klog.Errorf("logical router does not exist %v at %v", err, time.Now())
return
}
lrRouteList, err := c.ovnClient.GetLogicalRouterRouteByOpts(util.OvnICKey, util.OvnICValue)
// due to old ovn version, filter method is adapted
lrRouteList, err := c.ovnClient.GetLogicalRouterRouteByExtIds(util.OvnICExtKey)
if err != nil {
klog.Errorf("failed to list lr ovn-ic route %v", err)
return
Expand Down
14 changes: 14 additions & 0 deletions pkg/ovs/ovn-nb-logical_router_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ func (c OvnClient) GetLogicalRouterRouteByOpts(key, value string) ([]ovnnb.Logic
return lrRouteList, nil
}

func (c OvnClient) GetLogicalRouterRouteByExtIds(key string) ([]ovnnb.LogicalRouterStaticRoute, error) {
var lrRouteList []ovnnb.LogicalRouterStaticRoute
err := c.ovnNbClient.WhereCache(
func(lrroute *ovnnb.LogicalRouterStaticRoute) bool {
_, ok := lrroute.ExternalIDs[key]
return ok
}).List(context.TODO(), &lrRouteList)
if err != nil && err != client.ErrNotFound {
return nil, err
}

return lrRouteList, nil
}

func (c OvnClient) GetLogicalRouterPoliciesByExtID(key, value string) ([]ovnnb.LogicalRouterPolicy, error) {

var lrPolicyList []ovnnb.LogicalRouterPolicy
Expand Down
5 changes: 3 additions & 2 deletions pkg/util/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ const (
AttachmentProvider = "ovn.kubernetes.io/attchmentprovider"
LbSvcPodImg = "ovn.kubernetes.io/lb_svc_img"

OvnICKey = "origin"
OvnICValue = "connected"
OvnICKey = "origin"
OvnICValue = "connected"
OvnICExtKey = "ic-learned-route"

MatchV4Src = "ip4.src"
MatchV4Dst = "ip4.dst"
Expand Down

0 comments on commit 417176e

Please sign in to comment.