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
This commit is contained in:
Radomir Dopieralski 2023-11-27 16:53:47 +01:00
parent 2b03b44f3a
commit 1ea4f4d76f
7 changed files with 78 additions and 20 deletions

View File

@ -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
----

View File

@ -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']

View File

@ -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()])

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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.