Browse Source

Merge "Avoids unnecessary lock logging every loop"

Zuul 1 year ago
parent
commit
ed242ced72

+ 2
- 1
networking_hyperv/neutron/agent/layer2.py View File

@@ -417,7 +417,8 @@ class Layer2Agent(base_agent.BaseAgent):
417 417
             self._utils.update_cache()
418 418
             self._refresh_cache = False
419 419
 
420
-        eventlet.spawn_n(self._notify_plugin_on_port_updates)
420
+        if self._bound_ports or self._unbound_ports:
421
+            eventlet.spawn_n(self._notify_plugin_on_port_updates)
421 422
 
422 423
         # notify plugin about port deltas
423 424
         if self._added_ports:

+ 12
- 0
networking_hyperv/tests/unit/neutron/agent/test_layer2.py View File

@@ -615,6 +615,7 @@ class TestLayer2Agent(test_base.HyperVBaseTestCase):
615 615
     def test_work(self, mock_spawn, mock_treat_dev_added,
616 616
                   mock_treat_dev_removed):
617 617
         self._agent._refresh_cache = True
618
+        self._agent._bound_ports = set([mock.sentinel.bound_port])
618 619
         self._agent._added_ports = set([mock.sentinel.bound_port])
619 620
         self._agent._removed_ports = set([mock.sentinel.unbound_port])
620 621
 
@@ -627,6 +628,17 @@ class TestLayer2Agent(test_base.HyperVBaseTestCase):
627 628
         mock_treat_dev_added.assert_called_once_with()
628 629
         mock_treat_dev_removed.assert_called_once_with()
629 630
 
631
+    @mock.patch.object(agent_base.Layer2Agent, '_treat_devices_removed')
632
+    @mock.patch.object(agent_base.Layer2Agent, '_treat_devices_added')
633
+    @mock.patch('eventlet.spawn_n')
634
+    def test_work_noop(self, mock_spawn, mock_treat_dev_added,
635
+                       mock_treat_dev_removed):
636
+        self._agent._work()
637
+
638
+        self.assertFalse(mock_spawn.called)
639
+        self.assertFalse(mock_treat_dev_added.called)
640
+        self.assertFalse(mock_treat_dev_removed.called)
641
+
630 642
     def test_port_update_not_found(self):
631 643
         self._agent._utils.vnic_port_exists.return_value = False
632 644
         port = {'id': mock.sentinel.port_id}

Loading…
Cancel
Save