Skip to content

Commit

Permalink
ignore empty strings when counting lbs
Browse files Browse the repository at this point in the history
  • Loading branch information
ruijzhan committed Jul 28, 2021
1 parent 4818a83 commit e3daee8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ 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"))
count := len(strings.FieldsFunc(output, func(c rune) bool { return c == '\n' }))
if count > 1 {
klog.Errorf("%s has %d lb entries", lb, count)
return "", fmt.Errorf("%s has %d lb entries", lb, count)
Expand Down

0 comments on commit e3daee8

Please sign in to comment.