From 6b93e9dd8713f41fd50242499cc5413c26780714 Mon Sep 17 00:00:00 2001 From: Rodrigo Barbieri Date: Tue, 23 Jan 2024 12:24:58 -0300 Subject: [PATCH] Allow configure of OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES If network calls to retrieve ports and floating IPs take too long, then the project > instances page cannot be loaded. This config allows disabling the network calls when loading the page with minor side-effects, as a workaround to avoid downtime while other performance optimizations can be done on the side to allow the page the load so the workaround is no longer needed. Closes-bug: #2051003 Related-bug: #2045168 Change-Id: Iedad6ef48cbe0b776594f4ad8276d3d713cd360c --- config.yaml | 12 ++++++++++++ hooks/horizon_contexts.py | 2 ++ templates/bobcat/local_settings.py | 2 +- templates/stein/local_settings.py | 2 +- templates/zed/local_settings.py | 2 +- unit_tests/test_horizon_contexts.py | 23 +++++++++++++++++++++++ 6 files changed, 40 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index ca1c7fcc..d3011422 100644 --- a/config.yaml +++ b/config.yaml @@ -492,6 +492,18 @@ options: description: | This option can be used to toggle the Router/Floating-IP panel visibility in dashboard. Set True for visibility and False to hide. + retrieve-network-data-when-listing-instances: + type: boolean + default: True + description: | + By setting this option to False, it can be used as a workaround to improve performance and + avoid downtime when the Project > Instances page is timing out due to the neutron requests + to retrieve ports and floating IPs taking too long. The side effect is that actions such + as adding/removing floating IPs or interfaces no longer immediately update the network + data in instance list, requiring a manual reload of the page. The default value for this + config is True. For more information see + https://docs.openstack.org/horizon/latest/configuration/settings.html#openstack-instance-retrieve-ip-addresses + and LP#2045168. wsgi-socket-rotation: type: boolean default: True diff --git a/hooks/horizon_contexts.py b/hooks/horizon_contexts.py index 0d37bbb1..18879a0a 100644 --- a/hooks/horizon_contexts.py +++ b/hooks/horizon_contexts.py @@ -274,6 +274,8 @@ class HorizonContext(OSContextGenerator): config('create-instance-flavor-sort-reverse'), 'enable_router_panel': config('enable-router-panel'), + 'retrieve_network_data_when_listing_instances': + config('retrieve-network-data-when-listing-instances'), } return ctxt diff --git a/templates/bobcat/local_settings.py b/templates/bobcat/local_settings.py index 576694f7..2b7c1c3d 100644 --- a/templates/bobcat/local_settings.py +++ b/templates/bobcat/local_settings.py @@ -15,7 +15,7 @@ from openstack_dashboard.settings import HORIZON_CONFIG DEBUG = {{ debug }} TEMPLATE_DEBUG = DEBUG - +OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES = {{ retrieve_network_data_when_listing_instances }} # WEBROOT is the location relative to Webserver root # should end with a slash. diff --git a/templates/stein/local_settings.py b/templates/stein/local_settings.py index 37ff01bc..a15052bc 100644 --- a/templates/stein/local_settings.py +++ b/templates/stein/local_settings.py @@ -15,7 +15,7 @@ from openstack_dashboard.settings import HORIZON_CONFIG DEBUG = {{ debug }} TEMPLATE_DEBUG = DEBUG - +OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES = {{ retrieve_network_data_when_listing_instances }} # WEBROOT is the location relative to Webserver root # should end with a slash. diff --git a/templates/zed/local_settings.py b/templates/zed/local_settings.py index dac24eb5..6c8b75ca 100644 --- a/templates/zed/local_settings.py +++ b/templates/zed/local_settings.py @@ -15,7 +15,7 @@ from openstack_dashboard.settings import HORIZON_CONFIG DEBUG = {{ debug }} TEMPLATE_DEBUG = DEBUG - +OPENSTACK_INSTANCE_RETRIEVE_IP_ADDRESSES = {{ retrieve_network_data_when_listing_instances }} # WEBROOT is the location relative to Webserver root # should end with a slash. diff --git a/unit_tests/test_horizon_contexts.py b/unit_tests/test_horizon_contexts.py index b9726b33..a719c39d 100644 --- a/unit_tests/test_horizon_contexts.py +++ b/unit_tests/test_horizon_contexts.py @@ -146,6 +146,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -187,6 +188,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -229,6 +231,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -273,6 +276,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": 'vcpus', "create_instance_flavor_sort_reverse": True, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -316,6 +320,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": False, + "retrieve_network_data_when_listing_instances": True, } ) @@ -358,6 +363,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -399,6 +405,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -440,6 +447,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -482,6 +490,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -527,6 +536,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -568,6 +578,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -578,6 +589,8 @@ class TestHorizonContexts(CharmTestCase): self.test_config.set('neutron-network-firewall', True) self.test_config.set('neutron-network-vpn', True) self.test_config.set('cinder-backup', True) + self.test_config.set( + 'retrieve-network-data-when-listing-instances', False) self.assertEqual(horizon_contexts.HorizonContext()(), {'compress_offline': True, 'debug': False, 'customization_module': '', @@ -614,6 +627,8 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": ( + False), } ) @@ -655,6 +670,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -696,6 +712,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -738,6 +755,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -780,6 +798,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -822,6 +841,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -864,6 +884,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -906,6 +927,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -952,6 +974,7 @@ class TestHorizonContexts(CharmTestCase): "create_instance_flavor_sort_key": None, "create_instance_flavor_sort_reverse": False, "enable_router_panel": True, + "retrieve_network_data_when_listing_instances": True, } )