Skip to content

Commit

Permalink
fix: lb bugs
Browse files Browse the repository at this point in the history
1. do not add lb to node switch.
2. delete lb with empty backends for performance reason.
3. update ovn-central for src-ip issues
  • Loading branch information
oilbeater committed Apr 12, 2019
1 parent 5de6ceb commit 1d753c8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dist/images/Dockerfile.controller
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitc
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-devel-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-common-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-vtep-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-central-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-central-2.10.1-2.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-host-2.10.1-1.el7.centos.x86_64.rpm

WORKDIR /kube-ovn
Expand Down
2 changes: 1 addition & 1 deletion dist/images/Dockerfile.node
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitc
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-devel-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-common-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-vtep-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-central-2.10.1-1.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-central-2.10.1-2.el7.centos.x86_64.rpm && \
rpm -i https://github.com/oilbeater/ovs/releases/download/v2.10.1/openvswitch-ovn-host-2.10.1-1.el7.centos.x86_64.rpm

RUN mkdir -p /var/run/openvswitch && \
Expand Down
31 changes: 25 additions & 6 deletions pkg/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,33 @@ func (c *Controller) handleUpdateEndpoint(key string) error {
targetPort = port
}
if port.Protocol == v1.ProtocolTCP {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterTcpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to tcp lb, %v", vip, err)
// for performance reason delete lb with no backends
if len(backends) > 0 {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterTcpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to tcp lb, %v", vip, err)
return err
}
} else {
err = c.ovnClient.DeleteLoadBalancerVip(vip, c.config.ClusterTcpLoadBalancer)
if err != nil {
klog.Errorf("failed to delete vip %s at tcp lb, %v", vip, err)
return err
}
}
} else {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterUdpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to udp lb, %v", vip, err)
if len(backends) > 0 {
err = c.ovnClient.CreateLoadBalancerRule(c.config.ClusterUdpLoadBalancer, vip, convertIpToAddress(backends, targetPort))
if err != nil {
klog.Errorf("failed to update vip %s to udp lb, %v", vip, err)
return err
}
} else {
err = c.ovnClient.DeleteLoadBalancerVip(vip, c.config.ClusterUdpLoadBalancer)
if err != nil {
klog.Errorf("failed to delete vip %s at udp lb, %v", vip, err)
return err
}
}
}
}
Expand Down
25 changes: 12 additions & 13 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,20 @@ func (c Client) CreateLogicalSwitch(ls, subnet, gateway, excludeIps string) erro
klog.Errorf("failed to connect switch %s to router, %v", ls, err)
return err
}
if ls != c.NodeSwitch {
// DO NOT add ovn dns/lb to node switch
err = c.AddLoadBalancerToLogicalSwitch(c.ClusterTcpLoadBalancer, ls)
if err != nil {
klog.Errorf("failed to add cluster tcp lb to %s, %v", ls, err)
return err
}

err = c.AddLoadBalancerToLogicalSwitch(c.ClusterTcpLoadBalancer, ls)
if err != nil {
klog.Errorf("failed to add cluster tcp lb to %s, %v", ls, err)
return err
}

err = c.AddLoadBalancerToLogicalSwitch(c.ClusterUdpLoadBalancer, ls)
if err != nil {
klog.Errorf("failed to add cluster udp lb to %s, %v", ls, err)
return err
}
err = c.AddLoadBalancerToLogicalSwitch(c.ClusterUdpLoadBalancer, ls)
if err != nil {
klog.Errorf("failed to add cluster udp lb to %s, %v", ls, err)
return err
}

// DO NOT add ovn dns to node switch
if ls != c.NodeSwitch {
err = c.AddDnsTableToLogicalSwitch(ls)
if err != nil {
klog.Errorf("failed to add cluster dns to %s, %v", ls, err)
Expand Down

0 comments on commit 1d753c8

Please sign in to comment.