diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-08-19 20:51:25 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-08-19 20:51:25 +0000 |
commit | 007654a9b667db8baa11e43358878a17b55b214f (patch) | |
tree | 91a61cb0d694a261abaf8d525fe7da8f039e8185 | |
parent | 8de195a3d5561d91bbf963adf5601f82492e04c0 (diff) | |
parent | 9e4b769055d0d4ca136afa0b1865930cc2cec6d7 (diff) | |
download | ironic-python-agent-007654a9b667db8baa11e43358878a17b55b214f.tar.gz |
Merge "Build socket list right before select call"
-rw-r--r-- | ironic_python_agent/netutils.py | 3 | ||||
-rw-r--r-- | ironic_python_agent/tests/unit/test_netutils.py | 9 | ||||
-rw-r--r-- | releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml | 4 |
3 files changed, 13 insertions, 3 deletions
diff --git a/ironic_python_agent/netutils.py b/ironic_python_agent/netutils.py index ccf73c14..801833a3 100644 --- a/ironic_python_agent/netutils.py +++ b/ironic_python_agent/netutils.py @@ -162,13 +162,12 @@ def _get_lldp_info(interfaces): if not interfaces: return {} - socks = [interface[1] for interface in interfaces] - while interfaces: LOG.info('Waiting on LLDP info for interfaces: %(interfaces)s, ' 'timeout: %(timeout)s', {'interfaces': interfaces, 'timeout': CONF.lldp_timeout}) + socks = [interface[1] for interface in interfaces] # rlist is a list of sockets ready for reading rlist, _, _ = select.select(socks, [], [], CONF.lldp_timeout) if not rlist: diff --git a/ironic_python_agent/tests/unit/test_netutils.py b/ironic_python_agent/tests/unit/test_netutils.py index 2bafff4f..257a556e 100644 --- a/ironic_python_agent/tests/unit/test_netutils.py +++ b/ironic_python_agent/tests/unit/test_netutils.py @@ -113,7 +113,8 @@ class TestNetutils(test_base.BaseTestCase): sock_mock.side_effect = [sock1, sock2] select_mock.side_effect = [ - ([sock1, sock2], [], []), + ([sock1], [], []), + ([sock2], [], []), ] lldp_info = netutils.get_lldp_info(interface_names) @@ -131,6 +132,12 @@ class TestNetutils(test_base.BaseTestCase): # 2 interfaces, 2 calls to enter promiscuous mode, 1 to leave self.assertEqual(6, fcntl_mock.call_count) + expected_calls = [ + mock.call([sock1, sock2], [], [], cfg.CONF.lldp_timeout), + mock.call([sock2], [], [], cfg.CONF.lldp_timeout), + ] + self.assertEqual(expected_calls, select_mock.call_args_list) + @mock.patch('fcntl.ioctl') @mock.patch('select.select') @mock.patch('socket.socket') diff --git a/releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml b/releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml new file mode 100644 index 00000000..343f29bd --- /dev/null +++ b/releasenotes/notes/lldp-loop-fdfa584caf33d847.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - Fixed incorrect invocation of "select" which could cause LLDP collection + to hang under certain conditions. |