Skip to content

Commit

Permalink
clean up legacy u2o implement
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Jan 16, 2023
1 parent 9092956 commit e99da12
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 59 deletions.
2 changes: 0 additions & 2 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,6 @@ spec:
type: string
natOutgoing:
type: boolean
u2oRouting:
type: boolean
externalEgressGateway:
type: string
policyRoutingPriority:
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ type SubnetSpec struct {
GatewayType string `json:"gatewayType,omitempty"`
GatewayNode string `json:"gatewayNode"`
NatOutgoing bool `json:"natOutgoing"`
U2oRouting bool `json:"u2oRouting,omitempty"`

ExternalEgressGateway string `json:"externalEgressGateway,omitempty"`
PolicyRoutingPriority uint32 `json:"policyRoutingPriority,omitempty"`
Expand Down
58 changes: 5 additions & 53 deletions pkg/daemon/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
}

var mtu int
var node *v1.Node
if providerNetwork != "" {
if node, err = csh.Controller.nodesLister.Get(csh.Config.NodeName); err != nil {
node, err := csh.Controller.nodesLister.Get(csh.Config.NodeName)
if err != nil {
errMsg := fmt.Errorf("failed to get node %s: %v", csh.Config.NodeName, err)
klog.Error(errMsg)
if err = resp.WriteHeaderAndEntity(http.StatusInternalServerError, request.CniResponse{Err: errMsg.Error()}); err != nil {
Expand All @@ -254,63 +254,15 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
mtu = csh.Config.MTU
}

// routes used for access from underlay to overlay
var u2oRoutes []request.Route
if podSubnet.Spec.U2oRouting && podSubnet.Spec.Vlan != "" &&
!podSubnet.Spec.LogicalGateway && podSubnet.Spec.Vpc == util.DefaultVpc {
subnets, err := csh.Controller.subnetsLister.List(labels.Everything())
if err != nil {
errMsg := fmt.Errorf("failed to list subnets: %v", err)
klog.Error(errMsg)
if err = resp.WriteHeaderAndEntity(http.StatusInternalServerError, request.CniResponse{Err: errMsg.Error()}); err != nil {
klog.Errorf("failed to write response: %v", err)
}
return
}

if node == nil {
if node, err = csh.Controller.nodesLister.Get(csh.Config.NodeName); err != nil {
errMsg := fmt.Errorf("failed to get node %s: %v", csh.Config.NodeName, err)
klog.Error(errMsg)
if err = resp.WriteHeaderAndEntity(http.StatusInternalServerError, request.CniResponse{Err: errMsg.Error()}); err != nil {
klog.Errorf("failed to write response: %v", err)
}
return
}
}

podCidrV4, podCidrV6 := util.SplitStringIP(cidr)
nodeIPv4, nodeIPv6 := util.GetNodeInternalIP(*node)
v4Routing := util.CIDRContainIP(podCidrV4, nodeIPv4)
v6Routing := util.CIDRContainIP(podCidrV6, nodeIPv6)
for _, subnet := range subnets {
if subnet.Spec.Vpc == util.DefaultVpc && (subnet.Spec.Vlan == "" || subnet.Spec.LogicalGateway) {
if !subnet.Status.IsReady() {
klog.V(5).Infof("subnet %s is not ready, skip", subnet.Name)
continue
}

cidrV4, cidrV6 := util.SplitStringIP(subnet.Spec.CIDRBlock)
if v4Routing && cidrV4 != "" {
u2oRoutes = append(u2oRoutes, request.Route{Destination: cidrV4, Gateway: nodeIPv4})
}
if v6Routing && cidrV6 != "" {
u2oRoutes = append(u2oRoutes, request.Route{Destination: cidrV6, Gateway: nodeIPv6})
}
}
}
}

klog.Infof("create container interface %s mac %s, ip %s, cidr %s, gw %s, u2o routes %v, custom routes %v", ifName, macAddr, ipAddr, cidr, gw, u2oRoutes, podRequest.Routes)
klog.Infof("create container interface %s mac %s, ip %s, cidr %s, gw %s, custom routes %v", ifName, macAddr, ipAddr, cidr, gw, podRequest.Routes)
detectIPConflict := podSubnet.Spec.Vlan != ""
allRoutes := append(u2oRoutes, podRequest.Routes...)
if nicType == util.InternalType {
podNicName, err = csh.configureNicWithInternalPort(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider, podRequest.NetNs, podRequest.ContainerID, ifName, macAddr, mtu, ipAddr, gw, isDefaultRoute, detectIPConflict, allRoutes, podRequest.DNS.Nameservers, podRequest.DNS.Search, ingress, egress, priority, podRequest.DeviceID, nicType, latency, limit, loss, gatewayCheckMode, u2oInterconnectionIP)
podNicName, err = csh.configureNicWithInternalPort(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider, podRequest.NetNs, podRequest.ContainerID, ifName, macAddr, mtu, ipAddr, gw, isDefaultRoute, detectIPConflict, podRequest.Routes, podRequest.DNS.Nameservers, podRequest.DNS.Search, ingress, egress, priority, podRequest.DeviceID, nicType, latency, limit, loss, gatewayCheckMode, u2oInterconnectionIP)
} else if nicType == util.DpdkType {
err = csh.configureDpdkNic(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider, podRequest.NetNs, podRequest.ContainerID, ifName, macAddr, mtu, ipAddr, gw, ingress, egress, priority, getShortSharedDir(pod.UID, podRequest.VhostUserSocketVolumeName), podRequest.VhostUserSocketName)
} else {
podNicName = ifName
err = csh.configureNic(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider, podRequest.NetNs, podRequest.ContainerID, podRequest.VfDriver, ifName, macAddr, mtu, ipAddr, gw, isDefaultRoute, detectIPConflict, allRoutes, podRequest.DNS.Nameservers, podRequest.DNS.Search, ingress, egress, priority, podRequest.DeviceID, nicType, latency, limit, loss, gatewayCheckMode, u2oInterconnectionIP)
err = csh.configureNic(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider, podRequest.NetNs, podRequest.ContainerID, podRequest.VfDriver, ifName, macAddr, mtu, ipAddr, gw, isDefaultRoute, detectIPConflict, podRequest.Routes, podRequest.DNS.Nameservers, podRequest.DNS.Search, ingress, egress, priority, podRequest.DeviceID, nicType, latency, limit, loss, gatewayCheckMode, u2oInterconnectionIP)
}
if err != nil {
errMsg := fmt.Errorf("configure nic failed %v", err)
Expand Down
1 change: 0 additions & 1 deletion pkg/util/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func TestValidateSubnet(t *testing.T) {
GatewayType: "distributed",
GatewayNode: "",
NatOutgoing: false,
U2oRouting: false,
ExternalEgressGateway: "",
PolicyRoutingPriority: 0,
PolicyRoutingTableID: 0,
Expand Down
2 changes: 0 additions & 2 deletions yamls/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,6 @@ spec:
type: string
natOutgoing:
type: boolean
u2oRouting:
type: boolean
externalEgressGateway:
type: string
policyRoutingPriority:
Expand Down

0 comments on commit e99da12

Please sign in to comment.