Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up legacy u2o implement #2248

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
@@ -1412,8 +1412,6 @@ spec:
type: string
natOutgoing:
type: boolean
u2oRouting:
type: boolean
externalEgressGateway:
type: string
policyRoutingPriority:
1 change: 0 additions & 1 deletion pkg/apis/kubeovn/v1/types.go
Original file line number Diff line number Diff line change
@@ -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"`
58 changes: 5 additions & 53 deletions pkg/daemon/handler.go
Original file line number Diff line number Diff line change
@@ -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)
1 change: 0 additions & 1 deletion pkg/util/validator_test.go
Original file line number Diff line number Diff line change
@@ -50,7 +50,6 @@ func TestValidateSubnet(t *testing.T) {
GatewayType: "distributed",
GatewayNode: "",
NatOutgoing: false,
U2oRouting: false,
ExternalEgressGateway: "",
PolicyRoutingPriority: 0,
PolicyRoutingTableID: 0,
2 changes: 0 additions & 2 deletions yamls/crd.yaml
Original file line number Diff line number Diff line change
@@ -789,8 +789,6 @@ spec:
type: string
natOutgoing:
type: boolean
u2oRouting:
type: boolean
externalEgressGateway:
type: string
policyRoutingPriority: