From e3daee8306ab1d71957f01db5de8890e5d31194c Mon Sep 17 00:00:00 2001 From: Ruijian Zhang Date: Wed, 28 Jul 2021 11:19:25 +0800 Subject: [PATCH] ignore empty strings when counting lbs --- pkg/ovs/ovn-nbctl.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ovs/ovn-nbctl.go b/pkg/ovs/ovn-nbctl.go index 5f7a0c0c900..534578e71ad 100644 --- a/pkg/ovs/ovn-nbctl.go +++ b/pkg/ovs/ovn-nbctl.go @@ -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)