Skip to content

Commit 6d58456

Browse files
MOS CIGerrit Code Review
authored andcommitted
Merge "[ovn] Handle vxlan network type"
2 parents 76a4ea2 + c5baf31 commit 6d58456

4 files changed

Lines changed: 98 additions & 2 deletions

File tree

rockoon/cli/ovs_ovn_migration.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,41 @@ def check(self):
611611
return routed_nets
612612

613613

614+
class TenantNetworkTypesCheck(CheckBase):
615+
616+
name = "Neutron tenant network types check"
617+
impact = CheckImpact.MAJOR
618+
error_message = (
619+
"Found tenant_network_types option containing VXLAN network type. "
620+
"Recommended network type for OVN is Geneve. "
621+
"When migrating to OVN all existing VXLAN networks will be converted "
622+
"to Geneve regardless of this setting. In case VXLAN was the default "
623+
"tenant network type it will be replaced by Geneve."
624+
)
625+
626+
def check(self):
627+
LOG.info("Checking Neutron tenant_network_types")
628+
osdpl = kube.get_osdpl()
629+
mspec = osdpl.mspec
630+
result = []
631+
features_path = ["features", "neutron", "tenant_network_types"]
632+
features_tnt = utils.get_in(mspec, features_path, [])
633+
if "vxlan" in features_tnt:
634+
result.append(":".join(features_path))
635+
636+
base_path = ["services", "networking", "neutron", "values", "conf"]
637+
neutron_conf = utils.get_in(mspec, base_path, {})
638+
tnt_paths = utils.find_key_paths(neutron_conf, "tenant_network_types")
639+
for path in tnt_paths:
640+
if "ml2" == path[-1]:
641+
tnt_path = list(path) + ["tenant_network_types"]
642+
services_tnt = utils.get_in(neutron_conf, tnt_path, "")
643+
if "vxlan" in services_tnt:
644+
result.append(":".join(base_path + tnt_path))
645+
LOG.info("Finished checking Neutron tenant_network_types")
646+
return result
647+
648+
614649
class SubnetsNoDHCPCheck(CheckBase):
615650
name = "Subnets without enabled DHCP check"
616651
impact = CheckImpact.CRITICAL

rockoon/templates/services/networking.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,14 @@
114114
{%- set cadf_audit = spec.get('features', {}).get('logging', {}).get('cadf', {'enabled': false}) %}
115115
{%- set cadf_audit_driver = spec.get('features', {}).get('logging', {}).get('cadf', {}).get('driver', 'messagingv2') %}
116116

117-
{%- set neutron_tenant_network_types = spec.get('features', {}).get('neutron', {}).get('tenant_network_types', default_tenant_network_types) %}
117+
{%- set tenant_network_types = spec.features.neutron.get('tenant_network_types', []) %}
118+
# first network type is default one, vxlan have a lot of limitations in OVN
119+
{%- if ovn_enabled and tenant_network_types and tenant_network_types[0] == 'vxlan' %}
120+
{%- set neutron_tenant_network_types = default_tenant_network_types + tenant_network_types %}
121+
{%- else %}
122+
{%- set neutron_tenant_network_types = tenant_network_types or default_tenant_network_types %}
123+
{%- endif %}
124+
118125
{%- if 'vxlan' in neutron_tenant_network_types %}
119126
{%- set l3_ha_network_type = 'vxlan' %}
120127
{%- elif 'geneve' in neutron_tenant_network_types %}
@@ -1007,7 +1014,7 @@ spec:
10071014
{%- if 'dns' in spec.features.services %}
10081015
- dns_domain_ports
10091016
{%- endif %}
1010-
tenant_network_types: {{ spec.features.neutron.get('tenant_network_types', default_tenant_network_types)|join(',') }}
1017+
tenant_network_types: {{ neutron_tenant_network_types|join(',') }}
10111018
{%- if baremetal_enabled %}
10121019
ngs_coordination:
10131020
backend_url: {{ get_etcd3_endpoint(spec.openstack_version, 'etcd3gw') }}

rockoon/utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,34 @@ def get_in(d: Dict, keys: List, default=None):
5757
return default
5858

5959

60+
def find_key_paths(data, target_key, parent_path=None):
61+
"""
62+
Recursively finds all parent key paths leading to a target key in a nested dictionary.
63+
Nested lists of dictionaries are not supported.
64+
65+
:param data: Dictionary to search.
66+
:param target_key: Key to search for.
67+
:param parent_path: Internal use for recursion.
68+
:return: Set of tuples, each containing the parent keys leading to the target key.
69+
"""
70+
if parent_path is None:
71+
parent_path = tuple()
72+
73+
found_paths = []
74+
75+
if isinstance(data, dict):
76+
for key, value in data.items():
77+
# If we find the target key
78+
if key == target_key:
79+
found_paths.append(parent_path)
80+
# Recurse into nested dictionaries
81+
if isinstance(value, dict):
82+
found_paths.extend(
83+
find_key_paths(value, target_key, parent_path + (key,))
84+
)
85+
return set(found_paths)
86+
87+
6088
OSCTL_LOGGING_CONF_FILE = os.environ.get(
6189
"OSCTL_LOGGING_CONF_FILE", "/etc/rockoon/logging.conf"
6290
)

tests/unit/test_utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@
1919
from rockoon import exception
2020

2121

22+
def test_find_key_paths():
23+
assert {("a", "b")} == utils.find_key_paths(
24+
{"a": {"b": {"c": {}, "d": {"e": {}}}}}, "c"
25+
)
26+
assert {("a", "b"), ("a", "b", "d", "e")} == utils.find_key_paths(
27+
{"a": {"b": {"c": {}, "d": {"e": {"c": {}}}}}}, "c"
28+
)
29+
assert set() == utils.find_key_paths({"a": {}}, "c")
30+
assert {tuple()} == utils.find_key_paths({"c": {}}, "c")
31+
assert {("a", "f"), ("a", "b")} == utils.find_key_paths(
32+
{"a": {"f": {"c": {}}, "b": {"c": {}}}}, "c"
33+
)
34+
assert {("b",)} == utils.find_key_paths(
35+
{"a": {"f": {"d": "c"}}, "b": {"c": {"e": {}}}}, "c"
36+
)
37+
assert {("f",), ("a", "b")} == utils.find_key_paths(
38+
{"f": {"c": {"g": "e"}}, "a": {"d": {}, "b": {"c": {}}}}, "c"
39+
)
40+
assert {("f",), ("a", "b"), ("a", "d")} == utils.find_key_paths(
41+
{"f": {"c": {"g": "e"}}, "a": {"d": {"c": {}}, "b": {"c": {}}}}, "c"
42+
)
43+
assert {("f",)} == utils.find_key_paths(
44+
{"f": {"c": []}, "a": [{"c": "d"}, {"g": "e"}]}, "c"
45+
)
46+
47+
2248
def test_divide_into_groups_of():
2349
assert [["a", "b", "c"]] == utils.divide_into_groups_of(3, ["a", "b", "c"])
2450
assert [["a", "b"], ["c", "d"], ["e"]] == utils.divide_into_groups_of(

0 commit comments

Comments
 (0)