本文记录自己在OVN部署和测试中遇到的问题,以及排查过程
前世今生:
近期在调研OVN,因此就试着搭建了一套openstack/pike版本的OVN。使用OVN作为网络底层实现而替换neutron的各类plugin(L3,DHCP,L2,iptables)
问题出现:
当创建port时,执行neutron port-create [net-id] --name [port-name]命令时,执行失败,log报错如下:
File "/usr/lib/python2.7/site-packages/ovsdbapp/backend/ovs_idl/connection.py", line 97, in run
txn.results.put(txn.do_commit())
File "/usr/lib/python2.7/site-packages/ovsdbapp/backend/ovs_idl/transaction.py", line 86, in do_commit
command.run_idl(txn)
File "/usr/lib/python2.7/site-packages/networking_ovn/ovsdb/commands.py", line 725, in run_idl
raise RuntimeError(msg)
RuntimeError: Address set as_ip4_b5dbdfe6_bcd3_4e39_b43a_0c37c66ccb54 does not exist. Can't update addresses
错误排查
1、根据报错,我们去看一下commands.py文件中run_idl函数,
根据函数之间的相互调用,我们发现起始调用该代码的地方在ovn-client.py中的create_port函数。
def create_port(self, port):
if utils.is_lsp_ignored(port):
return
port_info = self._get_port_options(port)
external_ids = {ovn_const.OVN_PORT_NAME_EXT_ID_KEY: port['name'],
ovn_const.OVN_DEVID_EXT_ID_KEY: port['device_id'],
ovn_const.OVN_PROJID_EXT_ID_KEY: port['project_id'],
ovn_const.OVN_CIDRS_EXT_ID_KEY: port_info.cidrs}
lswitch_name = utils.ovn_name(port['network_id'])
admin_context = n_context.get_admin_context()
sg_cache = {}
subnet_cache = {}
# It's possible to have a network created on one controller and then a
# port created on a different controller quickly enough that the second
# controller does not yet see that network in its local cache of the
# OVN northbound database. Check if the logical switch is present
# or not in the idl's local copy of the database before creating
# the lswitch port.
self._nb_idl.check_for_row_by_value_and_retry(
'Logical_Switch', 'name', lswitch_name)
with self._nb_idl.transaction(check_error=True) as txn:
if not port_info.dhcpv4_options:
dhcpv4_options = []
elif 'cmd' in port_info.dhcpv4_options:
dhcpv4_options = txn.add(port_info.dhcpv4_options['cmd'])
else:
dhcpv4_options = [port_info.dhcpv4_options['uuid']]
if not port_info.dhcpv6_options:
dhcpv6_options = []
elif 'cmd' in port_info.dhcpv6_options:
dhcpv6_options = txn.add(port_info.dhcpv6_options['cmd'])
else:
dhcpv6_options = [port_info.dhcpv6_options['uuid']]
# The lport_name *must* be neutron port['id']. It must match the
# iface-id set in the Interfaces table of the Open_vSwitch
# database which nova sets to be the port ID.
txn.add(self._nb_idl.create_lswitch_port(
lport_name=port['id'],
lswitch_name=lswitch_name,
addresses=port_info.addresses,
external_ids=external_ids,
parent_name=port_info.parent_name,
tag=port_info.tag,
enabled=port.get('admin_state_up'),
options=port_info.options,
type=port_info.type,
port_security=port_info.port_security,
dhcpv4_options=dhcpv4_options,
dhcpv6_options=dhcpv6_options))
acls_new = ovn_acl.add_acls(self._plugin, admin_context,
port, sg_cache, subnet_cache)
for acl in acls_new:
txn.add(self._nb_idl.add_acl(**acl))
sg_ids = utils.get_lsp_security_groups(port)
if port.get('fixed_ips') and sg_ids:
addresses = ovn_acl.acl_port_ips(port)
# NOTE(rtheis): Fail port creation if the address set doesn't
# exist. This prevents ports from being created on any security
# groups out-of-sync between neutron and OVN.
for sg_id in sg_ids:
for ip_version in addresses:
if addresses[ip_version]:
txn.add(self._nb_idl.update_address_set(
name=utils.ovn_addrset_name(sg_id,
ip_version),
addrs_add=addresses[ip_version],
addrs_remove=None,
if_exists=False))
<