[OVN] Populate the "router.distributed" flag in ML2/OVN
In ML2/OVN there is a static common configuration parameter to define if the routers (more in particular the floating IPs) can be distributed or centralized: [ovn] enable_distributed_floating_ip This patch writes this value on each new router created. It also implements a maintenance method to populate this flag when the Neutron API is restarted and the value changed. Closes-Bug: #2022058 Change-Id: Ib109b09fde4db8738c1d0b3e394c201492d210c6
This commit is contained in:
parent
1879d92533
commit
1f1824397d
@ -24,9 +24,10 @@ Frequently Asked Questions
|
|||||||
| | VRRP traffic. | tunnel endpoints to detect |
|
| | VRRP traffic. | tunnel endpoints to detect |
|
||||||
| | | connectivity issues to nodes. |
|
| | | connectivity issues to nodes. |
|
||||||
+---------------+---------------------------+--------------------------------+
|
+---------------+---------------------------+--------------------------------+
|
||||||
| DVR | exposes the "distributed" | no "distributed" flag is shown |
|
| DVR | exposes the "distributed" | exposes the "distributed" flag |
|
||||||
| API | flag on routers only | or available on routers via |
|
| API | flag on routers only | based on the configuration |
|
||||||
| | modifiable by admin. | API. |
|
| | modifiable by admin. | option |
|
||||||
|
| | | enable_distributed_floating_ip |
|
||||||
+---------------+---------------------------+--------------------------------+
|
+---------------+---------------------------+--------------------------------+
|
||||||
| DVR | uses namespaces, veths, | Uses OpenFlow rules on the |
|
| DVR | uses namespaces, veths, | Uses OpenFlow rules on the |
|
||||||
| dataplane | ip routing, ip rules and | compute nodes. |
|
| dataplane | ip routing, ip rules and | compute nodes. |
|
||||||
|
@ -136,6 +136,12 @@ class RouterExtraAttributes(base.NeutronDbObject):
|
|||||||
|
|
||||||
return list(query)
|
return list(query)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@db_api.CONTEXT_WRITER
|
||||||
|
def update_distributed_flag(cls, context, distributed):
|
||||||
|
query = context.session.query(cls.db_model)
|
||||||
|
query.update({'distributed': distributed})
|
||||||
|
|
||||||
def obj_make_compatible(self, primitive, target_version):
|
def obj_make_compatible(self, primitive, target_version):
|
||||||
_target_version = versionutils.convert_version_to_tuple(target_version)
|
_target_version = versionutils.convert_version_to_tuple(target_version)
|
||||||
if _target_version < (1, 1):
|
if _target_version < (1, 1):
|
||||||
|
@ -1095,6 +1095,25 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
|
|||||||
|
|
||||||
raise periodics.NeverAgain()
|
raise periodics.NeverAgain()
|
||||||
|
|
||||||
|
@has_lock_periodic(spacing=86400, run_immediately=True)
|
||||||
|
def update_router_distributed_flag(self):
|
||||||
|
"""Set "enable_distributed_floating_ip" on the router.distributed flag.
|
||||||
|
|
||||||
|
This method is needed to sync the static configuration parameter
|
||||||
|
"enable_distributed_floating_ip", loaded when the Neutron API starts,
|
||||||
|
and the router.distributed flag.
|
||||||
|
|
||||||
|
NOTE: remove this method when the RFE that allows to define the
|
||||||
|
distributed flag per FIP is implemented. At this point, the
|
||||||
|
router.distributed flag will be useless.
|
||||||
|
RFE: https://bugs.launchpad.net/neutron/+bug/1978039
|
||||||
|
"""
|
||||||
|
distributed = ovn_conf.is_ovn_distributed_floating_ip()
|
||||||
|
router_obj.RouterExtraAttributes.update_distributed_flag(
|
||||||
|
n_context.get_admin_context(), distributed)
|
||||||
|
|
||||||
|
raise periodics.NeverAgain()
|
||||||
|
|
||||||
|
|
||||||
class HashRingHealthCheckPeriodics(object):
|
class HashRingHealthCheckPeriodics(object):
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ from neutron._i18n import _
|
|||||||
from neutron.common.ovn import constants as ovn_const
|
from neutron.common.ovn import constants as ovn_const
|
||||||
from neutron.common.ovn import extensions
|
from neutron.common.ovn import extensions
|
||||||
from neutron.common.ovn import utils
|
from neutron.common.ovn import utils
|
||||||
|
from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf
|
||||||
from neutron.db.availability_zone import router as router_az_db
|
from neutron.db.availability_zone import router as router_az_db
|
||||||
from neutron.db import dns_db
|
from neutron.db import dns_db
|
||||||
from neutron.db import extraroute_db
|
from neutron.db import extraroute_db
|
||||||
@ -174,6 +175,10 @@ class OVNL3RouterPlugin(service_base.ServicePluginBase,
|
|||||||
context.session.flush()
|
context.session.flush()
|
||||||
router_id = payload.resource_id
|
router_id = payload.resource_id
|
||||||
router_db = payload.metadata['router_db']
|
router_db = payload.metadata['router_db']
|
||||||
|
# NOTE(ralonsoh): the "distributed" flag is a static configuration
|
||||||
|
# parameter that needs to be defined only during the router creation.
|
||||||
|
extra_attr = router_db['extra_attributes']
|
||||||
|
extra_attr.distributed = ovn_conf.is_ovn_distributed_floating_ip()
|
||||||
|
|
||||||
db_rev.create_initial_revision(
|
db_rev.create_initial_revision(
|
||||||
context, router_id, ovn_const.TYPE_ROUTERS,
|
context, router_id, ovn_const.TYPE_ROUTERS,
|
||||||
|
@ -61,6 +61,16 @@ class RouterExtraAttrsDbObjTestCase(obj_test_base.BaseDbObjectTestCase,
|
|||||||
self.update_obj_fields(
|
self.update_obj_fields(
|
||||||
{'router_id': lambda: self._create_test_router_id()})
|
{'router_id': lambda: self._create_test_router_id()})
|
||||||
|
|
||||||
|
def test_update_distributed_flag(self):
|
||||||
|
for obj in self.objs:
|
||||||
|
obj.distributed = False
|
||||||
|
obj.create()
|
||||||
|
router.RouterExtraAttributes.update_distributed_flag(self.context,
|
||||||
|
True)
|
||||||
|
r_e_a_list = router.RouterExtraAttributes.get_objects(self.context)
|
||||||
|
for obj in r_e_a_list:
|
||||||
|
self.assertTrue(obj.distributed)
|
||||||
|
|
||||||
|
|
||||||
class RouterIfaceObjectTestCase(obj_test_base.BaseObjectIfaceTestCase):
|
class RouterIfaceObjectTestCase(obj_test_base.BaseObjectIfaceTestCase):
|
||||||
|
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
OVN routers now expose the "distributed" flag depending on the
|
||||||
|
configuration option ``enable_distributed_floating_ip``. Because this is a
|
||||||
|
common configuration option, all routers will expose the same value. This
|
||||||
|
value can flap if the Neutron API is restarted and the configuration option
|
||||||
|
changes.
|
||||||
|
NOTE: Once the RFE that allows us to define the distributed flag per
|
||||||
|
floating IP address is implemented in ML2/OVN, this flag will be useless
|
||||||
|
(no Launchpad bug has been created yet for this RFE, that is only a
|
||||||
|
proposed idea during several PTGs).
|
Loading…
Reference in New Issue
Block a user