From 46895dab0de5fab3db2f59d4566afcbb28540fd8 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 (cherry picked from commit 6b93e9dd8713f41fd50242499cc5413c26780714) (cherry picked from commit 45a86be78ab883fd40d1936c26876b734f0e263f) (cherry picked from commit 1ec179bb9d3faeac5d01660399671095ec452e69) (cherry picked from commit 9e2ae8e65b63185dbd579f957dcf14f5d3ee91cf) (cherry picked from commit b2af81e75d681142f31265fa6e457a7e19fc6717) (cherry picked from commit 7eb985778c9973581440214b05442baea1714d2f) (cherry picked from commit 560adf4ac34cded5eda456b43b35bfebb3311868) (cherry picked from commit 5d4080d351106d7bc33d10300eb0bf5c27e2cc08) --- config.yaml | 12 ++++++++++++ hooks/horizon_contexts.py | 2 ++ templates/stein/local_settings.py | 2 +- unit_tests/test_horizon_contexts.py | 20 ++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/config.yaml b/config.yaml index 14399622..d712b067 100644 --- a/config.yaml +++ b/config.yaml @@ -428,6 +428,18 @@ options: Openstack mostly defaults to using public endpoints for internal communication between services. If set to True this option will configure services to use internal endpoints where possible. + 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 a568013a..e8ea442d 100644 --- a/hooks/horizon_contexts.py +++ b/hooks/horizon_contexts.py @@ -257,6 +257,8 @@ class HorizonContext(OSContextGenerator): config('disable-instance-snapshot')), 'disable_password_reveal': config('disable-password-reveal'), 'enforce_password_check': config('enforce-password-check'), + 'retrieve_network_data_when_listing_instances': + config('retrieve-network-data-when-listing-instances'), } return ctxt diff --git a/templates/stein/local_settings.py b/templates/stein/local_settings.py index 4e02326e..4720451a 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/unit_tests/test_horizon_contexts.py b/unit_tests/test_horizon_contexts.py index 4d30ef89..5cececdc 100644 --- a/unit_tests/test_horizon_contexts.py +++ b/unit_tests/test_horizon_contexts.py @@ -126,6 +126,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -161,6 +162,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -197,6 +199,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": True, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -233,6 +236,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": False, + "retrieve_network_data_when_listing_instances": True, } ) @@ -268,6 +272,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -303,6 +308,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -339,6 +345,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -378,6 +385,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -413,6 +421,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -423,6 +432,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': '', @@ -453,6 +464,8 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": ( + False), } ) @@ -488,6 +501,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -523,6 +537,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -559,6 +574,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -595,6 +611,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -631,6 +648,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -667,6 +685,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } ) @@ -703,6 +722,7 @@ class TestHorizonContexts(CharmTestCase): "disable_instance_snapshot": False, "disable_password_reveal": False, "enforce_password_check": True, + "retrieve_network_data_when_listing_instances": True, } )