Skip to content

Commit 6d78b14

Browse files
committed
Add support for AZs when creating network resources
Octavia needs to support configuring availability zones to ensure the LB management resources are scheduled appropriately when AZs are configured. Jira: OSPRH-6901
1 parent fa4d732 commit 6d78b14

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

api/bases/octavia.openstack.org_octavias.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ spec:
107107
description: OctaviaLbMgmtNetworks Settings for Octavia management
108108
networks
109109
properties:
110+
availabilityZones:
111+
description: Availability zones for the octavia management network
112+
resources
113+
items:
114+
type: string
115+
type: array
110116
manageLbMgmtNetworks:
111117
default: true
112118
type: boolean

api/v1beta1/octavia_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,10 @@ type OctaviaLbMgmtNetworks struct {
217217
// +kubebuilder:default=4
218218
// IP Version of the managed subnets
219219
SubnetIPVersion int `json:"subnetIpVersion,omitempty"`
220+
221+
// +kubebuilder:validation:Optional
222+
// Availability zones for the octavia management network resources
223+
AvailabilityZones []string `json:"availabilityZones,omitempty"`
220224
}
221225

222226
// OctaviaAmphoraFlavor Settings for custom Amphora flavors

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/octavia.openstack.org_octavias.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ spec:
107107
description: OctaviaLbMgmtNetworks Settings for Octavia management
108108
networks
109109
properties:
110+
availabilityZones:
111+
description: Availability zones for the octavia management network
112+
resources
113+
items:
114+
type: string
115+
type: array
110116
manageLbMgmtNetworks:
111117
default: true
112118
type: boolean

pkg/octavia/lb_mgmt_network.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func ensureProvSubnet(client *gophercloud.ServiceClient, providerNetwork *networ
312312
return ensureSubnet(client, 4, createOpts, log)
313313
}
314314

315-
func ensureProvNetwork(client *gophercloud.ServiceClient, serviceTenantID string, log *logr.Logger) (
315+
func ensureProvNetwork(client *gophercloud.ServiceClient, netDetails *octaviav1.OctaviaLbMgmtNetworks, serviceTenantID string, log *logr.Logger) (
316316
*networks.Network, error) {
317317
_, err := getNetwork(client, LbProvNetName, serviceTenantID)
318318
if err != nil {
@@ -321,10 +321,11 @@ func ensureProvNetwork(client *gophercloud.ServiceClient, serviceTenantID string
321321

322322
asu := true
323323
createOpts := networks.CreateOpts{
324-
Name: LbProvNetName,
325-
Description: LbProvNetDescription,
326-
AdminStateUp: &asu,
327-
TenantID: serviceTenantID,
324+
Name: LbProvNetName,
325+
Description: LbProvNetDescription,
326+
AdminStateUp: &asu,
327+
TenantID: serviceTenantID,
328+
AvailabilityZoneHints: netDetails.AvailabilityZones,
328329
}
329330
provNet, err := ensureNetworkExt(client, createOpts, log, serviceTenantID)
330331
if err != nil {
@@ -407,10 +408,11 @@ func ensureLbMgmtNetwork(client *gophercloud.ServiceClient, networkDetails *octa
407408

408409
asu := true
409410
createOpts := networks.CreateOpts{
410-
Name: LbMgmtNetName,
411-
Description: LbMgmtNetDescription,
412-
AdminStateUp: &asu,
413-
TenantID: serviceTenantID,
411+
Name: LbMgmtNetName,
412+
Description: LbMgmtNetDescription,
413+
AdminStateUp: &asu,
414+
TenantID: serviceTenantID,
415+
AvailabilityZoneHints: networkDetails.AvailabilityZones,
414416
}
415417
mgmtNetwork, err = ensureNetwork(client, createOpts, log, serviceTenantID)
416418
if err != nil {
@@ -804,7 +806,7 @@ func EnsureAmphoraManagementNetwork(
804806
log.Error(err, "Unable to complete configuration of octavia provider network security groups, continuing...")
805807
}
806808

807-
providerNetwork, err := ensureProvNetwork(client, adminTenant.ID, log)
809+
providerNetwork, err := ensureProvNetwork(client, netDetails, adminTenant.ID, log)
808810
if err != nil {
809811
return NetworkProvisioningSummary{}, err
810812
}
@@ -835,9 +837,10 @@ func EnsureAmphoraManagementNetwork(
835837
}
836838
adminStateUp := true
837839
createOpts := routers.CreateOpts{
838-
Name: LbRouterName,
839-
AdminStateUp: &adminStateUp,
840-
GatewayInfo: &gatewayInfo,
840+
Name: LbRouterName,
841+
AdminStateUp: &adminStateUp,
842+
GatewayInfo: &gatewayInfo,
843+
AvailabilityZoneHints: netDetails.AvailabilityZones,
841844
}
842845
router, err = routers.Create(client, createOpts).Extract()
843846
if err != nil {

0 commit comments

Comments
 (0)