Skip to content

Commit f4f1580

Browse files
authored
Merge pull request #23 from stackhpc/upstream/yoga-2023-01-30
Synchronise yoga with upstream
2 parents 04d0ac5 + 5cb3428 commit f4f1580

File tree

12 files changed

+478
-245
lines changed

12 files changed

+478
-245
lines changed

neutron/agent/l3/dvr_edge_ha_router.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ def external_gateway_updated(self, ex_gw_port, interface_name):
134134

135135
def _external_gateway_added(self, ex_gw_port, interface_name,
136136
ns_name, preserve_ips):
137-
link_up = self.external_gateway_link_up()
138-
self._plug_external_gateway(ex_gw_port, interface_name, ns_name,
139-
link_up=link_up)
137+
self._plug_external_gateway(ex_gw_port, interface_name, ns_name)
140138

141139
def _is_this_snat_host(self):
142140
return self.agent_conf.agent_mode == constants.L3_AGENT_MODE_DVR_SNAT

neutron/agent/l3/ha.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,6 @@ def _enqueue_state_change(self, router_id, state):
188188
'agent %(host)s',
189189
state_change_data)
190190

191-
# Set external gateway port link up or down according to state
192-
if state == 'primary':
193-
ri.set_external_gw_port_link_status(link_up=True, set_gw=True)
194-
elif state == 'backup':
195-
ri.set_external_gw_port_link_status(link_up=False)
196-
else:
197-
LOG.warning('Router %s has status %s, '
198-
'no action to router gateway device.',
199-
router_id, state)
200191
# TODO(dalvarez): Fix bug 1677279 by moving the IPv6 parameters
201192
# configuration to keepalived-state-change in order to remove the
202193
# dependency that currently exists on l3-agent running for the IPv6

neutron/agent/l3/ha_router.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ def _init_keepalived_manager(self, process_monitor):
170170
throttle_restart_value=(
171171
self.agent_conf.ha_vrrp_advert_int * THROTTLER_MULTIPLIER))
172172

173+
# The following call is required to ensure that if the state path does
174+
# not exist it gets created.
175+
self.keepalived_manager.get_full_config_file_path('test')
176+
173177
config = self.keepalived_manager.config
174178

175179
interface_name = self.get_ha_device_name()
@@ -469,9 +473,7 @@ def _get_filtered_dict(d, ignore):
469473
return port1_filtered == port2_filtered
470474

471475
def external_gateway_added(self, ex_gw_port, interface_name):
472-
link_up = self.external_gateway_link_up()
473-
self._plug_external_gateway(ex_gw_port, interface_name,
474-
self.ns_name, link_up=link_up)
476+
self._plug_external_gateway(ex_gw_port, interface_name, self.ns_name)
475477
self._add_gateway_vip(ex_gw_port, interface_name)
476478
self._disable_ipv6_addressing_on_interface(interface_name)
477479

@@ -535,27 +537,3 @@ def enable_radvd(self, internal_ports=None):
535537
if (self.keepalived_manager.get_process().active and
536538
self.ha_state == 'primary'):
537539
super(HaRouter, self).enable_radvd(internal_ports)
538-
539-
def external_gateway_link_up(self):
540-
# Check HA router ha_state for its gateway port link state.
541-
# 'backup' instance will not link up the gateway port.
542-
return self.ha_state == 'primary'
543-
544-
def set_external_gw_port_link_status(self, link_up, set_gw=False):
545-
link_state = "up" if link_up else "down"
546-
LOG.info('Set router %s gateway device link state to %s.',
547-
self.router_id, link_state)
548-
549-
ex_gw_port = self.get_ex_gw_port()
550-
ex_gw_port_id = (ex_gw_port and ex_gw_port['id'] or
551-
self.ex_gw_port and self.ex_gw_port['id'])
552-
if ex_gw_port_id:
553-
interface_name = self.get_external_device_name(ex_gw_port_id)
554-
ns_name = self.get_gw_ns_name()
555-
self.driver.set_link_status(interface_name, ns_name,
556-
link_up=link_up)
557-
if link_up and set_gw:
558-
preserve_ips = self.get_router_preserve_ips()
559-
self._external_gateway_settings(ex_gw_port, interface_name,
560-
ns_name, preserve_ips)
561-
self.routes_updated([], self.routes)

neutron/agent/l3/router_info.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -750,16 +750,14 @@ def _list_floating_ip_cidrs(self):
750750
return [common_utils.ip_to_cidr(ip['floating_ip_address'])
751751
for ip in floating_ips]
752752

753-
def _plug_external_gateway(self, ex_gw_port, interface_name, ns_name,
754-
link_up=True):
753+
def _plug_external_gateway(self, ex_gw_port, interface_name, ns_name):
755754
self.driver.plug(ex_gw_port['network_id'],
756755
ex_gw_port['id'],
757756
interface_name,
758757
ex_gw_port['mac_address'],
759758
namespace=ns_name,
760759
prefix=EXTERNAL_DEV_PREFIX,
761-
mtu=ex_gw_port.get('mtu'),
762-
link_up=link_up)
760+
mtu=ex_gw_port.get('mtu'))
763761

764762
def _get_external_gw_ips(self, ex_gw_port):
765763
gateway_ips = []
@@ -819,11 +817,7 @@ def _external_gateway_added(self, ex_gw_port, interface_name,
819817
LOG.debug("External gateway added: port(%s), interface(%s), ns(%s)",
820818
ex_gw_port, interface_name, ns_name)
821819
self._plug_external_gateway(ex_gw_port, interface_name, ns_name)
822-
self._external_gateway_settings(ex_gw_port, interface_name,
823-
ns_name, preserve_ips)
824820

825-
def _external_gateway_settings(self, ex_gw_port, interface_name,
826-
ns_name, preserve_ips):
827821
# Build up the interface and gateway IP addresses that
828822
# will be added to the interface.
829823
ip_cidrs = common_utils.fixed_ip_cidrs(ex_gw_port['fixed_ips'])
@@ -868,19 +862,17 @@ def is_v6_gateway_set(self, gateway_ips):
868862
return any(netaddr.IPAddress(gw_ip).version == 6
869863
for gw_ip in gateway_ips)
870864

871-
def get_router_preserve_ips(self):
865+
def external_gateway_added(self, ex_gw_port, interface_name):
872866
preserve_ips = self._list_floating_ip_cidrs() + list(
873867
self.centralized_port_forwarding_fip_set)
874868
preserve_ips.extend(self.agent.pd.get_preserve_ips(self.router_id))
875-
return preserve_ips
876-
877-
def external_gateway_added(self, ex_gw_port, interface_name):
878-
preserve_ips = self.get_router_preserve_ips()
879869
self._external_gateway_added(
880870
ex_gw_port, interface_name, self.ns_name, preserve_ips)
881871

882872
def external_gateway_updated(self, ex_gw_port, interface_name):
883-
preserve_ips = self.get_router_preserve_ips()
873+
preserve_ips = self._list_floating_ip_cidrs() + list(
874+
self.centralized_port_forwarding_fip_set)
875+
preserve_ips.extend(self.agent.pd.get_preserve_ips(self.router_id))
884876
self._external_gateway_added(
885877
ex_gw_port, interface_name, self.ns_name, preserve_ips)
886878

neutron/agent/linux/interface.py

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,17 @@ def configure_ipv6_forwarding(namespace, dev_name, enabled):
256256
{'dev': dev_name, 'enabled': int(enabled)}]
257257
ip_lib.sysctl(cmd, namespace=namespace)
258258

259+
@abc.abstractmethod
260+
def plug_new(self, network_id, port_id, device_name, mac_address,
261+
bridge=None, namespace=None, prefix=None, mtu=None):
262+
"""Plug in the interface only for new devices that don't exist yet."""
263+
259264
def plug(self, network_id, port_id, device_name, mac_address,
260-
bridge=None, namespace=None, prefix=None, mtu=None, link_up=True):
265+
bridge=None, namespace=None, prefix=None, mtu=None):
261266
if not ip_lib.device_exists(device_name,
262267
namespace=namespace):
263268
self.plug_new(network_id, port_id, device_name, mac_address,
264-
bridge, namespace, prefix, mtu, link_up)
269+
bridge, namespace, prefix, mtu)
265270
else:
266271
LOG.info("Device %s already exists", device_name)
267272
if mtu:
@@ -293,21 +298,10 @@ def set_mtu(self, device_name, mtu, namespace=None, prefix=None):
293298
LOG.warning("Interface driver cannot update MTU for ports")
294299
self._mtu_update_warn_logged = True
295300

296-
def set_link_status(self, device_name, namespace=None, link_up=True):
297-
ns_dev = ip_lib.IPWrapper(namespace=namespace).device(device_name)
298-
if not ns_dev.exists():
299-
LOG.debug("Device %s may concurrently be deleted.", device_name)
300-
return
301-
if link_up:
302-
ns_dev.link.set_up()
303-
else:
304-
ns_dev.link.set_down()
305-
306301

307302
class NullDriver(LinuxInterfaceDriver):
308303
def plug_new(self, network_id, port_id, device_name, mac_address,
309-
bridge=None, namespace=None, prefix=None, mtu=None,
310-
link_up=True):
304+
bridge=None, namespace=None, prefix=None, mtu=None):
311305
pass
312306

313307
def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
@@ -385,8 +379,7 @@ def _add_device_to_namespace(self, ip_wrapper, device, namespace):
385379
namespace_obj.add_device_to_namespace(device)
386380

387381
def plug_new(self, network_id, port_id, device_name, mac_address,
388-
bridge=None, namespace=None, prefix=None, mtu=None,
389-
link_up=True):
382+
bridge=None, namespace=None, prefix=None, mtu=None):
390383
"""Plug in the interface."""
391384
if not bridge:
392385
bridge = self.conf.OVS.integration_bridge
@@ -442,8 +435,7 @@ def plug_new(self, network_id, port_id, device_name, mac_address,
442435
else:
443436
LOG.warning("No MTU configured for port %s", port_id)
444437

445-
if link_up:
446-
ns_dev.link.set_up()
438+
ns_dev.link.set_up()
447439
if self.conf.ovs_use_veth:
448440
# ovs-dpdk does not do checksum calculations for veth interface
449441
# (bug 1832021)
@@ -488,8 +480,7 @@ class BridgeInterfaceDriver(LinuxInterfaceDriver):
488480
DEV_NAME_PREFIX = 'ns-'
489481

490482
def plug_new(self, network_id, port_id, device_name, mac_address,
491-
bridge=None, namespace=None, prefix=None, mtu=None,
492-
link_up=True):
483+
bridge=None, namespace=None, prefix=None, mtu=None):
493484
"""Plugin the interface."""
494485
ip = ip_lib.IPWrapper()
495486

@@ -508,8 +499,7 @@ def plug_new(self, network_id, port_id, device_name, mac_address,
508499
LOG.warning("No MTU configured for port %s", port_id)
509500

510501
root_veth.link.set_up()
511-
if link_up:
512-
ns_veth.link.set_up()
502+
ns_veth.link.set_up()
513503

514504
def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
515505
"""Unplug the interface."""

0 commit comments

Comments
 (0)