From 95089025fda7c8cce6f7195e2a63f7f09efc9e0a Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Fri, 26 Jan 2024 15:10:41 -0300 Subject: [PATCH] Extend configurable skippability of neutron calls to project instance detail The OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES config aids in envs struggling to load the instance list due to having too many ports or bad neutron plugin performance. However, the config does not apply its effect to the instance detail page, which cannot be loaded due to the neutron calls taking too long. This patch extends the config option to the instance detail page, allowing the same benefit (and side-effects) of the instance list page. Related-bug: #2045168 Change-Id: I3e71a208a1c7212e168d63a259f2adddf27dbabf --- .../dashboards/project/instances/tests.py | 24 ++++++++++++++++--- .../dashboards/project/instances/views.py | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py index 5ab1b4a489..5e074a7005 100644 --- a/openstack_dashboard/dashboards/project/instances/tests.py +++ b/openstack_dashboard/dashboards/project/instances/tests.py @@ -1338,7 +1338,8 @@ class InstanceDetailTests(InstanceTestBase): def _get_instance_details(self, server, qs=None, flavor_return=None, volumes_return=None, security_groups_return=None, - flavor_exception=False, nova_api_ge_2_47=False): + flavor_exception=False, nova_api_ge_2_47=False, + skip_servers_update_addresses=False): url = reverse('horizon:project:instances:detail', args=[server.id]) if qs: @@ -1369,8 +1370,11 @@ class InstanceDetailTests(InstanceTestBase): self.mock_server_get.assert_called_once_with( helpers.IsHttpRequest(), server.id) - self.mock_servers_update_addresses.assert_called_once_with( - helpers.IsHttpRequest(), mock.ANY) + if skip_servers_update_addresses: + self.mock_servers_update_addresses.assert_not_called() + else: + self.mock_servers_update_addresses.assert_called_once_with( + helpers.IsHttpRequest(), mock.ANY) self.mock_instance_volumes_list.assert_called_once_with( helpers.IsHttpRequest(), server.id) if nova_api_ge_2_47: @@ -1408,6 +1412,20 @@ class InstanceDetailTests(InstanceTestBase): self.mock_is_extension_supported.assert_called_once_with( helpers.IsHttpRequest(), 'mac-learning') + @override_settings(OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES=False) + @helpers.create_mocks({api.neutron: ['is_extension_supported']}) + def test_instance_details_skip_servers_update_addresses(self): + server = self.servers.first() + + self.mock_is_extension_supported.return_value = False + + self._get_instance_details( + server, + skip_servers_update_addresses=True) + + self.mock_is_extension_supported.assert_called_once_with( + helpers.IsHttpRequest(), 'mac-learning') + @helpers.create_mocks({api.neutron: ['is_extension_supported']}) def test_instance_details_volume_sorting(self): server = self.servers.first() diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py index badf540b83..b91e00ea41 100644 --- a/openstack_dashboard/dashboards/project/instances/views.py +++ b/openstack_dashboard/dashboards/project/instances/views.py @@ -535,6 +535,8 @@ class DetailView(tabs.TabView): exceptions.handle(self.request, msg, ignore=True) def _update_addresses(self, instance): + if not settings.OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES: + return instance_id = instance.id try: api.network.servers_update_addresses(self.request, [instance])