Skip to content

Commit

Permalink
Fix GetPortAddresses for HBO
Browse files Browse the repository at this point in the history
In GetPortAddresses, we check if we have both PortMAC and IP for
the port. If not we return nil for both values. While this works
for normal ports, for the HBO ports which don't have IPs for
the int-<node> interface, we will always hit this condition and
return an empty PortMAC which in turn triggers the lsp-add even
if the portMAC already exists.

When we have an external entity updating the node object, the
watcher triggers handleOverlayPort and we keep hitting this
condition.

Let's remove the "len(addresses)<2" check since its not needed
for HBO and in normal pod port case, pods.getPortAddresses already
handles the case for empty podMac or podIPs. This way when portMAC
is set but not the IPs, we will still return the portMAC and the
respective code paths handle it as needed.

Signed-off-by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
  • Loading branch information
tssurya committed Aug 3, 2021
1 parent a96572f commit 1a6f9c9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
3 changes: 0 additions & 3 deletions go-controller/pkg/util/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ func GetPortAddresses(portName string, ovnNBClient goovn.Client) (net.HardwareAd
return nil, nil, nil
}

if len(addresses) < 2 {
return nil, nil, fmt.Errorf("error while obtaining addresses for %s: %v", portName, addresses)
}
mac, err := net.ParseMAC(addresses[0])
if err != nil {
return nil, nil, fmt.Errorf("failed to parse logical switch port %q MAC %q: %v", portName, addresses[0], err)
Expand Down
3 changes: 1 addition & 2 deletions go-controller/pkg/util/net_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ func TestGetPortAddresses(t *testing.T) {
onRetArgsOvnNBClient: &ovntest.TestifyMockHelper{OnCallMethodName: "LSPGet", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{&goovn.LogicalSwitchPort{DynamicAddresses: "06:c6:d4:fb:fb:ba 10.244.2.2"}, nil}},
},
{
desc: "test code path where addresses list count is less than 2",
desc: "test code path where port has MAC but no IPs",
inpPort: "TEST_PORT",
errMatch: fmt.Errorf("error while obtaining addresses for"),
onRetArgsOvnNBClient: &ovntest.TestifyMockHelper{OnCallMethodName: "LSPGet", OnCallMethodArgType: []string{"string"}, RetArgList: []interface{}{&goovn.LogicalSwitchPort{DynamicAddresses: "06:c6:d4:fb:fb:ba"}, nil}},
},
{
Expand Down

0 comments on commit 1a6f9c9

Please sign in to comment.