Switch to use cast method in dhcp_ready_on_ports method
When DHCP agent reports to the neutron-server which ports are
ready, it was using call() method from rpc client.
That caused blocking dhcp agent's dhcp_ready_ports_loop thread which
blocks to send info about other ready ports if there are any.
Method call() should be used when RPC caller returns a value to the
caller but that's not the case here. On neutron server side this
RPC method is only calling provisioning_complete() method to
finish provisioning of ports. And is not returning anything.
So to make sending dhcp ready ports to neutron-server much faster
this patch switch to use cast() method from rpc client.
This method don't block to wait for return value from RPC caller.
Change-Id: Ie119693854aa283b863a1eac2bdae3330c2b6a9d
Closes-Bug: #1850864
(cherry picked from commit 1a686fb401
)
This commit is contained in:
parent
6a4aefe666
commit
0b1aac544b
|
@ -234,9 +234,6 @@ class DhcpAgent(manager.Manager):
|
||||||
LOG.info("DHCP configuration for ports %s is completed",
|
LOG.info("DHCP configuration for ports %s is completed",
|
||||||
ports_to_send)
|
ports_to_send)
|
||||||
continue
|
continue
|
||||||
except oslo_messaging.MessagingTimeout:
|
|
||||||
LOG.error("Timeout notifying server of ports ready. "
|
|
||||||
"Retrying...")
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception("Failure notifying DHCP server of "
|
LOG.exception("Failure notifying DHCP server of "
|
||||||
"ready DHCP ports. Will retry on next "
|
"ready DHCP ports. Will retry on next "
|
||||||
|
@ -732,8 +729,8 @@ class DhcpPluginApi(object):
|
||||||
def dhcp_ready_on_ports(self, port_ids):
|
def dhcp_ready_on_ports(self, port_ids):
|
||||||
"""Notify the server that DHCP is configured for the port."""
|
"""Notify the server that DHCP is configured for the port."""
|
||||||
cctxt = self.client.prepare(version='1.5')
|
cctxt = self.client.prepare(version='1.5')
|
||||||
return cctxt.call(self.context, 'dhcp_ready_on_ports',
|
cctxt.cast(self.context, 'dhcp_ready_on_ports',
|
||||||
port_ids=port_ids)
|
port_ids=port_ids)
|
||||||
|
|
||||||
|
|
||||||
class NetworkCache(object):
|
class NetworkCache(object):
|
||||||
|
|
|
@ -430,20 +430,6 @@ class TestDhcpAgent(base.BaseTestCase):
|
||||||
dhcp.start_ready_ports_loop()
|
dhcp.start_ready_ports_loop()
|
||||||
spawn.assert_called_once_with(dhcp._dhcp_ready_ports_loop)
|
spawn.assert_called_once_with(dhcp._dhcp_ready_ports_loop)
|
||||||
|
|
||||||
def test__dhcp_ready_ports_doesnt_log_exception_on_timeout(self):
|
|
||||||
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
|
|
||||||
dhcp.dhcp_ready_ports = set(range(4))
|
|
||||||
|
|
||||||
with mock.patch.object(dhcp.plugin_rpc, 'dhcp_ready_on_ports',
|
|
||||||
side_effect=oslo_messaging.MessagingTimeout):
|
|
||||||
# exit after 2 iterations
|
|
||||||
with mock.patch.object(dhcp_agent.eventlet, 'sleep',
|
|
||||||
side_effect=[0, 0, RuntimeError]):
|
|
||||||
with mock.patch.object(dhcp_agent.LOG, 'exception') as lex:
|
|
||||||
with testtools.ExpectedException(RuntimeError):
|
|
||||||
dhcp._dhcp_ready_ports_loop()
|
|
||||||
self.assertFalse(lex.called)
|
|
||||||
|
|
||||||
def test__dhcp_ready_ports_loop(self):
|
def test__dhcp_ready_ports_loop(self):
|
||||||
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
|
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
|
||||||
dhcp.dhcp_ready_ports = set(range(4))
|
dhcp.dhcp_ready_ports = set(range(4))
|
||||||
|
|
Loading…
Reference in New Issue