[L3HA] Bind metadata haproxy to IPv6 address if IPv6 is enabled

Patch [1] added possibility that haproxy spawned as metadata proxy in
the router's namespace can be bound to IPv6 address.
We misssed to add the same for the HA router, so when router was
switched to be active on the node, L3 agent starts haproxy for that
router but it was always bound to IPv4 address only.
That patch fixes it by adding check if IPv6 is enabled on host, and if
yes, it adds same config to the haproxy like it is in non-ha mode.

[1] https://review.opendev.org/c/openstack/neutron/+/715483

Closes-Bug: #1915495
Change-Id: Ie97cfe9fe0020929d9a1736d55ad92a5bd643072
(cherry picked from commit ce8361a667)
This commit is contained in:
Slawek Kaplonski 2021-02-12 11:40:41 +01:00
parent 8307464174
commit 3452b41bf0
1 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import eventlet
from neutron_lib import constants
from oslo_log import log as logging
from oslo_utils import fileutils
from oslo_utils import netutils
import webob
from neutron.agent.linux import utils as agent_utils
@ -217,9 +218,12 @@ class AgentMixin(object):
# routers needs to serve metadata requests to local ports.
if state == 'primary' or ri.router.get('distributed', False):
LOG.debug('Spawning metadata proxy for router %s', router_id)
spawn_kwargs = {}
if netutils.is_ipv6_enabled():
spawn_kwargs['bind_address'] = '::'
self.metadata_driver.spawn_monitored_metadata_proxy(
self.process_monitor, ri.ns_name, self.conf.metadata_port,
self.conf, router_id=ri.router_id)
self.conf, router_id=ri.router_id, **spawn_kwargs)
else:
LOG.debug('Closing metadata proxy for router %s', router_id)
self.metadata_driver.destroy_monitored_metadata_proxy(