Skip to content

Commit

Permalink
fix removing default static route in default vpc (#2116)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Dec 5, 2022
1 parent 141c4c3 commit 625e317
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion pkg/controller/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,33 @@ func (c *Controller) handleAddOrUpdateVpc(key string) error {
return err
}

routeNeedDel, routeNeedAdd, err := diffStaticRoute(existRoute, vpc.Spec.StaticRoutes)
targetRoutes := vpc.Spec.StaticRoutes
if vpc.Name == c.config.ClusterRouter {
joinSubnet, err := c.subnetsLister.Get(c.config.NodeSwitch)
if err != nil {
if !k8serrors.IsNotFound(err) {
klog.Error("failed to get node switch subnet %s: %v", c.config.NodeSwitch)
return err
}
}
gatewayV4, gatewayV6 := util.SplitStringIP(joinSubnet.Spec.Gateway)
if gatewayV4 != "" {
targetRoutes = append(targetRoutes, &kubeovnv1.StaticRoute{
Policy: kubeovnv1.PolicyDst,
CIDR: "0.0.0.0/0",
NextHopIP: gatewayV4,
})
}
if gatewayV6 != "" {
targetRoutes = append(targetRoutes, &kubeovnv1.StaticRoute{
Policy: kubeovnv1.PolicyDst,
CIDR: "::/0",
NextHopIP: gatewayV6,
})
}
}

routeNeedDel, routeNeedAdd, err := diffStaticRoute(existRoute, targetRoutes)
if err != nil {
klog.Errorf("failed to diff vpc %s static route, %v", vpc.Name, err)
return err
Expand Down

0 comments on commit 625e317

Please sign in to comment.