Skip to content

Commit

Permalink
fix: missing session lb to logical switch
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Aug 20, 2020
1 parent f8d5879 commit e0096f9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func NewController(config *Configuration) *Controller {

controller := &Controller{
config: config,
ovnClient: ovs.NewClient(config.OvnNbHost, config.OvnNbPort, config.OvnTimeout, config.OvnSbHost, config.OvnSbPort, config.ClusterRouter, config.ClusterTcpLoadBalancer, config.ClusterUdpLoadBalancer, config.NodeSwitch, config.NodeSwitchCIDR),
ovnClient: ovs.NewClient(config.OvnNbHost, config.OvnNbPort, config.OvnTimeout, config.OvnSbHost, config.OvnSbPort, config.ClusterRouter, config.ClusterTcpLoadBalancer, config.ClusterUdpLoadBalancer, config.ClusterTcpSessionLoadBalancer, config.ClusterUdpSessionLoadBalancer, config.NodeSwitch, config.NodeSwitchCIDR),
ipam: ovnipam.NewIPAM(),

subnetsLister: subnetInformer.Lister(),
Expand Down
10 changes: 10 additions & 0 deletions pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,16 @@ func (c Client) CreateLogicalSwitch(ls, protocol, subnet, gateway string, exclud
klog.Errorf("failed to add cluster udp lb to %s, %v", ls, err)
return err
}

if err := c.addLoadBalancerToLogicalSwitch(c.ClusterTcpSessionLoadBalancer, ls); err != nil {
klog.Errorf("failed to add cluster tcp session lb to %s, %v", ls, err)
return err
}

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

return nil
Expand Down
40 changes: 22 additions & 18 deletions pkg/ovs/ovn.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ var (

// Client is the ovn client
type Client struct {
OvnNbAddress string
OvnTimeout int
OvnSbAddress string
OVNIcNBAddress string
ClusterRouter string
ClusterTcpLoadBalancer string
ClusterUdpLoadBalancer string
NodeSwitch string
NodeSwitchCIDR string
OvnNbAddress string
OvnTimeout int
OvnSbAddress string
OVNIcNBAddress string
ClusterRouter string
ClusterTcpLoadBalancer string
ClusterUdpLoadBalancer string
ClusterTcpSessionLoadBalancer string
ClusterUdpSessionLoadBalancer string
NodeSwitch string
NodeSwitchCIDR string
}

const (
Expand All @@ -35,15 +37,17 @@ const (
)

// NewClient init an ovn client
func NewClient(ovnNbHost string, ovnNbPort int, ovnNbTimeout int, ovnSbHost string, ovnSbPort int, clusterRouter, clusterTcpLoadBalancer, clusterUdpLoadBalancer, nodeSwitch, nodeSwitchCIDR string) *Client {
func NewClient(ovnNbHost string, ovnNbPort int, ovnNbTimeout int, ovnSbHost string, ovnSbPort int, clusterRouter, clusterTcpLoadBalancer, clusterUdpLoadBalancer, clusterTcpSessionLoadBalancer, clusterUdpSessionLoadBalancer, nodeSwitch, nodeSwitchCIDR string) *Client {
return &Client{
OvnNbAddress: fmt.Sprintf("tcp:%s:%d", ovnNbHost, ovnNbPort),
OvnSbAddress: fmt.Sprintf("tcp:%s:%d", ovnSbHost, ovnSbPort),
OvnTimeout: ovnNbTimeout,
ClusterRouter: clusterRouter,
ClusterTcpLoadBalancer: clusterTcpLoadBalancer,
ClusterUdpLoadBalancer: clusterUdpLoadBalancer,
NodeSwitch: nodeSwitch,
NodeSwitchCIDR: nodeSwitchCIDR,
OvnNbAddress: fmt.Sprintf("tcp:%s:%d", ovnNbHost, ovnNbPort),
OvnSbAddress: fmt.Sprintf("tcp:%s:%d", ovnSbHost, ovnSbPort),
OvnTimeout: ovnNbTimeout,
ClusterRouter: clusterRouter,
ClusterTcpLoadBalancer: clusterTcpLoadBalancer,
ClusterUdpLoadBalancer: clusterUdpLoadBalancer,
ClusterTcpSessionLoadBalancer: clusterTcpSessionLoadBalancer,
ClusterUdpSessionLoadBalancer: clusterUdpSessionLoadBalancer,
NodeSwitch: nodeSwitch,
NodeSwitchCIDR: nodeSwitchCIDR,
}
}
2 changes: 1 addition & 1 deletion pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewValidatingHook(c cache.Cache, opt *WebhookOptions) (*ValidatingHook, err

v := &ValidatingHook{
kubeclientset: kubeClient,
ovnClient: ovs.NewClient(opt.OvnNbHost, opt.OvnNbPort, opt.OvnNbTimeout, "", 0, "", "", "", "", ""),
ovnClient: ovs.NewClient(opt.OvnNbHost, opt.OvnNbPort, opt.OvnNbTimeout, "", 0, "", "", "", "", "", "", ""),
opt: opt,
cache: c,
}
Expand Down

0 comments on commit e0096f9

Please sign in to comment.