Skip to content

Commit

Permalink
Fix AZ awareness check for subgroups
Browse files Browse the repository at this point in the history
Hostgroups with a parent group generally don't have an
availability_zones attribute set, so they need to use the attribute from
their parent group to properly work.

Also, we didn't properly handle hostgroups that do not have an
availability_zones attribute set, so we now check for exactly one AZ
instead of "more than one".
  • Loading branch information
sebageek committed Aug 26, 2024
1 parent 8ee4453 commit 79c2a9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions networking_aci/plugins/ml2/drivers/mech_aci/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ def _parse_hostgroups(self):
.format(far_hg, hostgroup_name))
self._hostgroups[far_hg]['child_hostgroups'].append(hostgroup_name)

# copy over AZs so the AZ check works properly for subgroups
if not hostgroup['availability_zones']:
hostgroup['availability_zones'] = self._hostgroups[far_hg]['availability_zones']

if not hostgroup['baremetal_pc_policy_group']:
hostgroup['baremetal_pc_policy_group'] = CONF.ml2_aci.default_baremetal_pc_policy_group

Expand Down
2 changes: 1 addition & 1 deletion networking_aci/plugins/ml2/drivers/mech_aci/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def _check_port_az_affinity(self, context, network, port):
if az_hints:
az_hint = az_hints[0]
hg_az = [hostgroup['host_azs'][host]] if host in hostgroup['host_azs'] else hostgroup['availability_zones']
if len(hg_az) > 1 or az_hint != hg_az[0]:
if len(hg_az) != 1 or az_hint != hg_az[0]:
exc = aci_exc.HostgroupNetworkAZAffinityError(port_id=port['id'], hostgroup_name=hostgroup_name,
host=host, hostgroup_az=", ".join(hg_az),
network_az=az_hint)
Expand Down

0 comments on commit 79c2a9c

Please sign in to comment.