From 0a284020ad7530c87f06034f82075e918923d59f Mon Sep 17 00:00:00 2001 From: Erik Berg Date: Tue, 10 Jan 2023 17:33:53 +0100 Subject: [PATCH] Limit interface names to 15 characters If you give your bridge a long enough name, eg. `br-external`. The extra characters added to the veth pairs can make the interface name go beyond the 15 character limit. We can solve this by truncating the name of the bridge used in the veth names. Change-Id: I5b890e24195d033897a597a0a93a1cacfb2030d2 (cherry picked from commit b9b90a5d5ff38e5a64b8dbdd8d3dea32d097b3b1) --- kayobe/plugins/action/kolla_ansible_host_vars.py | 5 ++++- kayobe/plugins/filter/networks.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/kayobe/plugins/action/kolla_ansible_host_vars.py b/kayobe/plugins/action/kolla_ansible_host_vars.py index d03aac6aa..2a442b760 100644 --- a/kayobe/plugins/action/kolla_ansible_host_vars.py +++ b/kayobe/plugins/action/kolla_ansible_host_vars.py @@ -154,7 +154,10 @@ def _get_external_interface_facts(self, external_interfaces): # For a bridge, use a veth pair connected to the bridge. Otherwise # use the interface directly. if is_bridge: - external_interface = patch_prefix + interface + patch_suffix + # interface names can't be longer than 15 characters + char_limit = 15 - len(patch_prefix) - len(patch_suffix) + external_interface = patch_prefix + interface[:char_limit] + \ + patch_suffix else: external_interface = interface neutron_external_interfaces.append(external_interface) diff --git a/kayobe/plugins/filter/networks.py b/kayobe/plugins/filter/networks.py index ed9d23b96..3122757b1 100644 --- a/kayobe/plugins/filter/networks.py +++ b/kayobe/plugins/filter/networks.py @@ -49,7 +49,10 @@ def _get_veth_interface(context, bridge, inventory_hostname): inventory_hostname) suffix = utils.get_hostvar(context, 'network_patch_suffix_phy', inventory_hostname) - return prefix + bridge + suffix + + # interface names can't be longer than 15 characters + char_limit = 15 - len(prefix) - len(suffix) + return prefix + bridge[:char_limit] + suffix def _get_veth_peer(context, bridge, inventory_hostname): @@ -64,7 +67,10 @@ def _get_veth_peer(context, bridge, inventory_hostname): inventory_hostname) suffix = utils.get_hostvar(context, 'network_patch_suffix_ovs', inventory_hostname) - return prefix + bridge + suffix + + # interface names can't be longer than 15 characters + char_limit = 15 - len(prefix) - len(suffix) + return prefix + bridge[:char_limit] + suffix def get_ovs_veths(context, names, inventory_hostname):