Skip to content

Commit

Permalink
fix: use uuid to fetch vip
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Mar 4, 2020
1 parent e804548 commit 2546dea
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,11 @@ func (c Client) DeleteStaticRouteByNextHop(nextHop string) error {
func (c Client) FindLoadbalancer(lb string) (string, error) {
output, err := c.ovnNbCommand("--data=bare", "--no-heading", "--columns=_uuid",
"find", "load_balancer", fmt.Sprintf("name=%s", lb))
count := len(strings.Split(output, "/n"))
if count > 1 {
klog.Errorf("%s has %d lb entries", lb, count)
return "", fmt.Errorf("%s has %d lb entries", lb, count)
}
return output, err
}

Expand All @@ -266,7 +271,17 @@ func (c Client) addLoadBalancerToLogicalSwitch(lb, ls string) error {

// DeleteLoadBalancerVip delete a vip rule from loadbalancer
func (c Client) DeleteLoadBalancerVip(vip, lb string) error {
existVips, err := c.GetLoadBalancerVips(lb)
lbUuid, err := c.FindLoadbalancer(lb)
if err != nil {
klog.Errorf("failed to get lb %v", err)
return err
}

existVips, err := c.GetLoadBalancerVips(lbUuid)
if err != nil {
klog.Errorf("failed to list lb %s vips, %v", lb, err)
return err
}
// vip is empty or delete last rule will destroy the loadbalancer
if vip == "" || len(existVips) == 1 {
return nil
Expand Down

0 comments on commit 2546dea

Please sign in to comment.