Skip to content

Commit 30d9f70

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove unused wait_for_port_detach code"
2 parents a88aa18 + fd58750 commit 30d9f70

File tree

4 files changed

+0
-140
lines changed

4 files changed

+0
-140
lines changed

octavia/network/base.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -354,20 +354,6 @@ def get_network_configs(self, load_balancer, amphora=None):
354354
:raises: NotFound, NetworkNotFound, SubnetNotFound, PortNotFound
355355
"""
356356

357-
@abc.abstractmethod
358-
def wait_for_port_detach(self, amphora):
359-
"""Waits for the amphora ports device_id to be unset.
360-
361-
This method waits for the ports on an amphora device_id
362-
parameter to be '' or None which signifies that nova has
363-
finished detaching the port from the instance.
364-
365-
:param amphora: Amphora to wait for ports to detach.
366-
:returns: None
367-
:raises TimeoutException: Port did not detach in interval.
368-
:raises PortNotFound: Port was not found by neutron.
369-
"""
370-
371357
@abc.abstractmethod
372358
def update_vip_sg(self, load_balancer, vip):
373359
"""Updates the security group for a VIP

octavia/network/drivers/neutron/allowed_address_pairs.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -797,57 +797,6 @@ def get_network_configs(self, loadbalancer, amphora=None):
797797
{'amp': amp.id, 'err': str(e)})
798798
return amp_configs
799799

800-
# TODO(johnsom) This may be dead code now. Remove in failover for v2 patch
801-
def wait_for_port_detach(self, amphora):
802-
"""Waits for the amphora ports device_id to be unset.
803-
804-
This method waits for the ports on an amphora device_id
805-
parameter to be '' or None which signifies that nova has
806-
finished detaching the port from the instance.
807-
808-
:param amphora: Amphora to wait for ports to detach.
809-
:returns: None
810-
:raises TimeoutException: Port did not detach in interval.
811-
:raises PortNotFound: Port was not found by neutron.
812-
"""
813-
interfaces = self.get_plugged_networks(compute_id=amphora.compute_id)
814-
815-
ports = []
816-
port_detach_timeout = CONF.networking.port_detach_timeout
817-
for interface_ in interfaces:
818-
port = self.get_port(port_id=interface_.port_id)
819-
ips = port.fixed_ips
820-
lb_network = False
821-
for ip in ips:
822-
if ip.ip_address == amphora.lb_network_ip:
823-
lb_network = True
824-
if not lb_network:
825-
ports.append(port)
826-
827-
for port in ports:
828-
try:
829-
neutron_port = self.network_proxy.get_port(
830-
port.id)
831-
device_id = neutron_port['device_id']
832-
start = int(time.time())
833-
834-
while device_id:
835-
time.sleep(CONF.networking.retry_interval)
836-
neutron_port = self.network_proxy.get_port(
837-
port.id)
838-
device_id = neutron_port['device_id']
839-
840-
timed_out = int(time.time()) - start >= port_detach_timeout
841-
842-
if device_id and timed_out:
843-
message = ('Port %s failed to detach (device_id %s) '
844-
'within the required time (%s s).' %
845-
(port.id, device_id, port_detach_timeout))
846-
raise base.TimeoutException(message)
847-
848-
except os_exceptions.ResourceNotFound:
849-
pass
850-
851800
def delete_port(self, port_id):
852801
"""delete a neutron port.
853802

octavia/network/drivers/noop_driver/driver.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ def get_network_configs(self, loadbalancer, amphora=None):
352352

353353
return amp_configs
354354

355-
def wait_for_port_detach(self, amphora):
356-
LOG.debug("failover %s no-op, wait_for_port_detach, amphora id %s",
357-
self.__class__.__name__, amphora.id)
358-
359355
def get_qos_policy(self, qos_policy_id):
360356
LOG.debug("Qos Policy %s no-op, get_qos_policy qos_policy_id %s",
361357
self.__class__.__name__, qos_policy_id)
@@ -520,9 +516,6 @@ def plug_port(self, amphora, port):
520516
def get_network_configs(self, loadbalancer, amphora=None):
521517
return self.driver.get_network_configs(loadbalancer, amphora)
522518

523-
def wait_for_port_detach(self, amphora):
524-
self.driver.wait_for_port_detach(amphora)
525-
526519
def apply_qos_on_port(self, qos_id, port_id):
527520
self.driver.apply_qos_on_port(qos_id, port_id)
528521

octavia/tests/unit/network/drivers/neutron/test_allowed_address_pairs.py

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,74 +1496,6 @@ def test_get_network_configs(self):
14961496
configs = self.driver.get_network_configs(load_balancer_mock)
14971497
self.assertEqual(1, len(configs))
14981498

1499-
@mock.patch('time.sleep')
1500-
def test_wait_for_port_detach(self, mock_sleep):
1501-
amphora = data_models.Amphora(
1502-
id=self.AMPHORA_ID, load_balancer_id=self.LB_ID,
1503-
compute_id=self.COMPUTE_ID, status=self.ACTIVE,
1504-
lb_network_ip=self.LB_NET_IP, ha_port_id=self.HA_PORT_ID,
1505-
ha_ip=self.HA_IP)
1506-
ports = (p for p in [
1507-
Port(**{"fixed_ips": [{"subnet_id": self.SUBNET_ID_1,
1508-
"ip_address": self.IP_ADDRESS_1}],
1509-
"id": self.FIXED_IP_ID_1,
1510-
"network_id": self.NETWORK_ID_1}),
1511-
Port(**{"fixed_ips": [{"subnet_id": self.SUBNET_ID_2,
1512-
"ip_address": self.IP_ADDRESS_2}],
1513-
"id": self.FIXED_IP_ID_2,
1514-
"network_id": self.NETWORK_ID_2})])
1515-
show_port_1_without_device_id = Port(**{"fixed_ips": [
1516-
{"subnet_id": self.SUBNET_ID_1, "ip_address": self.IP_ADDRESS_1}],
1517-
"id": self.FIXED_IP_ID_1, "network_id": self.NETWORK_ID_1,
1518-
"device_id": ''})
1519-
show_port_2_with_device_id = Port(**{"fixed_ips": [
1520-
{"subnet_id": self.SUBNET_ID_2, "ip_address": self.IP_ADDRESS_2}],
1521-
"id": self.FIXED_IP_ID_2, "network_id": self.NETWORK_ID_2,
1522-
"device_id": self.DEVICE_ID})
1523-
show_port_2_without_device_id = Port(**{"fixed_ips": [
1524-
{"subnet_id": self.SUBNET_ID_2, "ip_address": self.IP_ADDRESS_2}],
1525-
"id": self.FIXED_IP_ID_2, "network_id": self.NETWORK_ID_2,
1526-
"device_id": None})
1527-
self.driver.network_proxy.ports.return_value = ports
1528-
self.driver.network_proxy.get_port = mock.MagicMock(
1529-
side_effect=[show_port_1_without_device_id,
1530-
show_port_2_with_device_id,
1531-
show_port_2_with_device_id,
1532-
show_port_2_without_device_id])
1533-
self.driver.wait_for_port_detach(amphora)
1534-
self.assertEqual(1, mock_sleep.call_count)
1535-
1536-
@mock.patch('time.time')
1537-
@mock.patch('time.sleep')
1538-
def test_wait_for_port_detach_timeout(self, mock_sleep, mock_time):
1539-
mock_time.side_effect = [1, 2, 6]
1540-
conf = oslo_fixture.Config(cfg.CONF)
1541-
conf.config(group="networking", port_detach_timeout=5)
1542-
amphora = data_models.Amphora(
1543-
id=self.AMPHORA_ID, load_balancer_id=self.LB_ID,
1544-
compute_id=self.COMPUTE_ID, status=self.ACTIVE,
1545-
lb_network_ip=self.LB_NET_IP, ha_port_id=self.HA_PORT_ID,
1546-
ha_ip=self.HA_IP)
1547-
ports = (p for p in [
1548-
Port(**{"fixed_ips": [{"subnet_id": self.SUBNET_ID_1,
1549-
"ip_address": self.IP_ADDRESS_1}],
1550-
"id": self.FIXED_IP_ID_1,
1551-
"network_id": self.NETWORK_ID_1}),
1552-
Port(**{"fixed_ips": [{"subnet_id": self.SUBNET_ID_2,
1553-
"ip_address": self.IP_ADDRESS_2}],
1554-
"id": self.FIXED_IP_ID_2,
1555-
"network_id": self.NETWORK_ID_2})])
1556-
show_port_1_with_device_id = Port(**{"fixed_ips": [
1557-
{"subnet_id": self.SUBNET_ID_2, "ip_address": self.IP_ADDRESS_2}],
1558-
"id": self.FIXED_IP_ID_2, "network_id": self.NETWORK_ID_2,
1559-
"device_id": self.DEVICE_ID})
1560-
self.driver.network_proxy.ports.return_value = ports
1561-
self.driver.network_proxy.get_port = mock.MagicMock(
1562-
return_value=show_port_1_with_device_id)
1563-
self.assertRaises(network_base.TimeoutException,
1564-
self.driver.wait_for_port_detach,
1565-
amphora)
1566-
15671499
def test_delete_port(self):
15681500
PORT_ID = uuidutils.generate_uuid()
15691501

0 commit comments

Comments
 (0)