Skip to content

Commit a82e61f

Browse files
Merge pull request #580 from richardcruise87/fix_issues_from_router_reconciliation_timeout
Fix condition where Octavia Provder Router might be missing port info
2 parents fbebe65 + c5516cd commit a82e61f

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

internal/octavia/lb_mgmt_network.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,36 @@ func EnsureAmphoraManagementNetwork(
10361036
log.Error(err, "Unable to create router object")
10371037
return NetworkProvisioningSummary{}, err
10381038
}
1039+
}
1040+
1041+
// Add interface to router if not already added
1042+
if tenantRouterPort != nil {
1043+
// Check if interface is already added to router
1044+
listOpts := ports.ListOpts{
1045+
DeviceID: router.ID,
1046+
}
1047+
allPages, err := ports.List(client, listOpts).AllPages(ctx)
1048+
if err != nil {
1049+
log.Error(err, fmt.Sprintf("Unable to list ports for router %s", router.ID))
1050+
return NetworkProvisioningSummary{}, err
1051+
}
1052+
1053+
allPorts, err := ports.ExtractPorts(allPages)
1054+
if err != nil {
1055+
log.Error(err, "Unable to extract port information from list")
1056+
return NetworkProvisioningSummary{}, err
1057+
}
1058+
1059+
hasInterface := false
1060+
for _, port := range allPorts {
1061+
if port.ID == tenantRouterPort.ID {
1062+
hasInterface = true
1063+
break
1064+
}
1065+
}
10391066

1040-
if tenantRouterPort != nil {
1067+
if !hasInterface {
1068+
log.Info("Adding interface info to octavia provider router")
10411069
interfaceOpts := routers.AddInterfaceOpts{
10421070
PortID: tenantRouterPort.ID,
10431071
}

test/functional/neutron_api_fixture.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ func (f *NeutronAPIFixture) getPort(w http.ResponseWriter, r *http.Request) {
435435
name := query["name"]
436436
tenantID := query["tenant_id"]
437437
networkID := query["network_id"]
438+
deviceID := query["device_id"]
438439
for _, port := range f.Ports {
439440
if len(name) > 0 && name[0] != port.Name {
440441
continue
@@ -445,6 +446,9 @@ func (f *NeutronAPIFixture) getPort(w http.ResponseWriter, r *http.Request) {
445446
if len(networkID) > 0 && networkID[0] != port.NetworkID {
446447
continue
447448
}
449+
if len(deviceID) > 0 && deviceID[0] != port.DeviceID {
450+
continue
451+
}
448452
n.Ports = append(n.Ports, port)
449453
}
450454
bytes, err := json.Marshal(&n)
@@ -612,6 +616,12 @@ func (f *NeutronAPIFixture) putRouter(w http.ResponseWriter, r *http.Request) {
612616
PortID: n.PortID,
613617
}
614618

619+
// Update the port's DeviceID to reflect it's attached to this router
620+
if port, ok := f.Ports[n.PortID]; ok {
621+
port.DeviceID = routerID
622+
f.Ports[n.PortID] = port
623+
}
624+
615625
bytes, err = json.Marshal(&n)
616626
if err != nil {
617627
f.InternalError(err, "Error during marshalling response", w, r)

0 commit comments

Comments
 (0)