Skip to content

Commit

Permalink
fix: index out of range err when create lsp
Browse files Browse the repository at this point in the history
when subnet address space has been exhausted with one ls,
the output when get dynamic address for one lsp will only
return mac for lsp, so cann't assume the output has both
ip and mac.
  • Loading branch information
qsyqian committed Nov 25, 2019
1 parent 623661e commit 61a7a7b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/ovs/ovn-nbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,13 @@ func (c Client) GetLogicalSwitchPortDynamicAddress(port string) ([]string, error
if output == "[]" {
return nil, ErrNoAddr
}
// "0a:00:00:00:00:02 100.64.0.3"
output = strings.Trim(output, `"`)
// "0a:00:00:00:00:02"
if len(strings.Split(output, " ")) == 1 {
klog.Error("Subnet address space has been exhausted")
return nil, ErrNoAddr
}
// "0a:00:00:00:00:02 100.64.0.3"
mac := strings.Split(output, " ")[0]
ip := strings.Split(output, " ")[1]
return []string{mac, ip}, nil
Expand Down

0 comments on commit 61a7a7b

Please sign in to comment.