From 1ea4f4d76f46ee7eefb0cdcb5ff4093fe48ba334 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 27 Nov 2023 16:53:47 +0100 Subject: [PATCH] Add a setting for disabling dhcp agents column in the admin network view Retrieving that information for every network can take considerable time on large deployments with large number of networks, and for some kinds of network drivers (ovn binary) this will be always zero anyways. This setting lets us disable that column to speed up the networks view. Change-Id: I1f1561916067d3f4a02f10ec9f62e8ba777a1501 --- doc/source/configuration/settings.rst | 14 ++++++++++ .../dashboards/admin/networks/tables.py | 17 ++++++------ .../dashboards/admin/networks/tests.py | 7 ++--- .../dashboards/admin/networks/utils.py | 27 +++++++++++++++++++ .../dashboards/admin/networks/views.py | 22 ++++++++------- openstack_dashboard/defaults.py | 4 +++ ...TACK_NEUTRON_NETWORK-c1c8e76c61c3d7f0.yaml | 7 +++++ 7 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 openstack_dashboard/dashboards/admin/networks/utils.py create mode 100644 releasenotes/notes/add-show_agents_column-setting-to-OPENSTACK_NEUTRON_NETWORK-c1c8e76c61c3d7f0.yaml diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index fdcec9db54..a0656842c0 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -1853,6 +1853,7 @@ Default: 'segmentation_id_range': {}, 'supported_provider_types': ["*"], 'supported_vnic_types': ["*"], + 'show_agents_column': True, } A dictionary of settings which can be used to enable optional services provided @@ -2104,6 +2105,19 @@ Example: ``['normal', 'direct']`` To disable VNIC type selection, set an empty list (``[]``) or ``None``. +show_agents_column +################## + +.. versionadded:: 2024.1(Caracal) + +Default ``True`` + +Decides whether the DHCP Agents column should be shown on the Admin Networks +panel. Retrieving data for that column takes time, and it may be advisable to +disable it on large deployments with a large number on networks to speed up +displaying of that view. + + Nova ---- diff --git a/openstack_dashboard/dashboards/admin/networks/tables.py b/openstack_dashboard/dashboards/admin/networks/tables.py index 2c4499d078..7c87dd03cb 100644 --- a/openstack_dashboard/dashboards/admin/networks/tables.py +++ b/openstack_dashboard/dashboards/admin/networks/tables.py @@ -22,9 +22,13 @@ from horizon import exceptions from horizon import tables from openstack_dashboard import api +from openstack_dashboard.dashboards.admin.networks \ + import utils as admin_utils from openstack_dashboard.dashboards.project.networks \ import tables as project_tables from openstack_dashboard import policy +from openstack_dashboard.utils import settings as setting_utils + LOG = logging.getLogger(__name__) @@ -117,12 +121,9 @@ class NetworksTable(tables.DataTable): "is supported") exceptions.handle(self.request, msg) del self.columns['availability_zones'] - try: - if not api.neutron.is_extension_supported(request, - 'dhcp_agent_scheduler'): - del self.columns['num_agents'] - except Exception: - msg = _("Unable to check if DHCP agent scheduler " - "extension is supported") - exceptions.handle(self.request, msg) + + show_agents_column = setting_utils.get_dict_config( + 'OPENSTACK_NEUTRON_NETWORK', 'show_agents_column') + if not (show_agents_column and + admin_utils.is_dhcp_agent_scheduler_supported(request)): del self.columns['num_agents'] diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py index f415d84b0a..ff5377ed4d 100644 --- a/openstack_dashboard/dashboards/admin/networks/tests.py +++ b/openstack_dashboard/dashboards/admin/networks/tests.py @@ -68,9 +68,10 @@ class NetworkTests(test.BaseAdminViewTests): test.IsHttpRequest(), single_page=True, limit=21, sort_dir='asc', sort_key='id') self.mock_tenant_list.assert_called_once_with(test.IsHttpRequest()) - self._check_is_extension_supported( - {'network_availability_zone': 1, - 'dhcp_agent_scheduler': len(self.networks.list()) + 1}) + self._check_is_extension_supported({ + 'network_availability_zone': 1, + 'dhcp_agent_scheduler': 2, + }) self.mock_list_dhcp_agent_hosting_networks.assert_has_calls( [mock.call(test.IsHttpRequest(), network.id) for network in self.networks.list()]) diff --git a/openstack_dashboard/dashboards/admin/networks/utils.py b/openstack_dashboard/dashboards/admin/networks/utils.py new file mode 100644 index 0000000000..384a775551 --- /dev/null +++ b/openstack_dashboard/dashboards/admin/networks/utils.py @@ -0,0 +1,27 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from horizon import exceptions + +from openstack_dashboard import api + + +def is_dhcp_agent_scheduler_supported(request): + try: + if api.neutron.is_extension_supported( + request, 'dhcp_agent_scheduler'): + return True + except Exception: + msg = _("Unable to check if DHCP agent scheduler " + "extension is supported") + exceptions.handle(request, msg) + return False diff --git a/openstack_dashboard/dashboards/admin/networks/views.py b/openstack_dashboard/dashboards/admin/networks/views.py index 50f15e59ca..4240af358b 100644 --- a/openstack_dashboard/dashboards/admin/networks/views.py +++ b/openstack_dashboard/dashboards/admin/networks/views.py @@ -23,6 +23,8 @@ from horizon import tabs from horizon.utils import memoized from openstack_dashboard import api +from openstack_dashboard.dashboards.admin.networks \ + import utils as admin_utils from openstack_dashboard.dashboards.project.networks.tabs import OverviewTab from openstack_dashboard.dashboards.project.networks import views as user_views from openstack_dashboard.utils import filters @@ -66,14 +68,12 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView): data = _("Unknown") try: - if api.neutron.is_extension_supported(self.request, - 'dhcp_agent_scheduler'): - # This method is called for each network. If agent-list cannot - # be retrieved, we will see many pop-ups. So the error message - # will be popup-ed in get_data() below. - agents = api.neutron.list_dhcp_agent_hosting_networks( - self.request, network) - data = len(agents) + # This method is called for each network. If agent-list cannot + # be retrieved, we will see many pop-ups. So the error message + # will be popup-ed in get_data() below. + agents = api.neutron.list_dhcp_agent_hosting_networks( + self.request, network) + data = len(agents) except Exception: msg = _('Unable to list dhcp agents hosting network.') exceptions.handle(self.request, msg) @@ -83,6 +83,7 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView): return getattr(self, "_needs_filter_first", False) def get_data(self): + networks = None try: marker, sort_dir = self._get_marker() @@ -120,7 +121,10 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView): networks = [] msg = _('Network list can not be retrieved.') exceptions.handle(self.request, msg) - if networks: + show_agents_column = setting_utils.get_dict_config( + 'OPENSTACK_NEUTRON_NETWORK', 'show_agents_column') + if (networks and show_agents_column and + admin_utils.is_dhcp_agent_scheduler_supported(self.request)): self.exception = False tenant_dict = self._get_tenant_list() for n in networks: diff --git a/openstack_dashboard/defaults.py b/openstack_dashboard/defaults.py index bb406b99c9..bf50dbcfdd 100644 --- a/openstack_dashboard/defaults.py +++ b/openstack_dashboard/defaults.py @@ -457,6 +457,10 @@ OPENSTACK_NEUTRON_NETWORK = { # list, the field will be a regular input field. # e.g. ['default', 'test'] 'physical_networks': [], + + # Show the column with the count of dhcp agents in the admin network view. + # Disable this on large deployments to avoid slowing down of this view. + 'show_agents_column': True, } # This settings controls whether IP addresses of servers are retrieved from diff --git a/releasenotes/notes/add-show_agents_column-setting-to-OPENSTACK_NEUTRON_NETWORK-c1c8e76c61c3d7f0.yaml b/releasenotes/notes/add-show_agents_column-setting-to-OPENSTACK_NEUTRON_NETWORK-c1c8e76c61c3d7f0.yaml new file mode 100644 index 0000000000..d42cf5f67b --- /dev/null +++ b/releasenotes/notes/add-show_agents_column-setting-to-OPENSTACK_NEUTRON_NETWORK-c1c8e76c61c3d7f0.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Add a new setting to the OPENSTACK_NEUTRON_NETWORK configuration, named + show_agents_column, that controls whether the DHCP Agents column should + be displayed in the network views. Disabling this may speed up display + on large deployments.