From 486e8ee254dd2c33de63da318d044305615c865b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Wed, 18 Jan 2023 15:14:46 +0800 Subject: [PATCH] clean up legacy u2o implement (#2248) --- dist/images/install.sh | 2 -- pkg/apis/kubeovn/v1/types.go | 1 - pkg/daemon/handler.go | 58 ++++-------------------------------- pkg/util/validator_test.go | 1 - yamls/crd.yaml | 2 -- 5 files changed, 5 insertions(+), 59 deletions(-) diff --git a/dist/images/install.sh b/dist/images/install.sh index 1de0652aca5..6bf66af08b0 100755 --- a/dist/images/install.sh +++ b/dist/images/install.sh @@ -1412,8 +1412,6 @@ spec: type: string natOutgoing: type: boolean - u2oRouting: - type: boolean externalEgressGateway: type: string policyRoutingPriority: diff --git a/pkg/apis/kubeovn/v1/types.go b/pkg/apis/kubeovn/v1/types.go index 7185fc68706..8843193749d 100644 --- a/pkg/apis/kubeovn/v1/types.go +++ b/pkg/apis/kubeovn/v1/types.go @@ -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"` diff --git a/pkg/daemon/handler.go b/pkg/daemon/handler.go index 0cf587abf7e..0e3d90a051e 100644 --- a/pkg/daemon/handler.go +++ b/pkg/daemon/handler.go @@ -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 { @@ -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) diff --git a/pkg/util/validator_test.go b/pkg/util/validator_test.go index eab4f7e19a7..1f180546419 100644 --- a/pkg/util/validator_test.go +++ b/pkg/util/validator_test.go @@ -50,7 +50,6 @@ func TestValidateSubnet(t *testing.T) { GatewayType: "distributed", GatewayNode: "", NatOutgoing: false, - U2oRouting: false, ExternalEgressGateway: "", PolicyRoutingPriority: 0, PolicyRoutingTableID: 0, diff --git a/yamls/crd.yaml b/yamls/crd.yaml index f5284b35a2b..78cc618d46f 100644 --- a/yamls/crd.yaml +++ b/yamls/crd.yaml @@ -789,8 +789,6 @@ spec: type: string natOutgoing: type: boolean - u2oRouting: - type: boolean externalEgressGateway: type: string policyRoutingPriority: