File 0001-Fix-network_topology-view-memory-and-file-leaks.patch of Package openstack-dashboard

From 978e5a3ab318fe26151d42d4f2418f54d2ab1d61 Mon Sep 17 00:00:00 2001
From: Darragh O'Reilly <doreilly@suse.com>
Date: Thu, 17 Dec 2020 15:25:12 +0000
Subject: [PATCH] Fix network_topology view memory and file leaks (bsc#1179084)

The results from get_microversion() don't change, but the call
always misses the cache because the key is made using the
WSGIRequest object which keeps changing. This patch fixes that
by using the memoized_with_request decorator which calls
get_microversion with parameters that don't change.
---
 openstack_dashboard/api/nova.py | 35 +++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/openstack_dashboard/api/nova.py b/openstack_dashboard/api/nova.py
index 7cede8ac9..934d32e13 100644
--- a/openstack_dashboard/api/nova.py
+++ b/openstack_dashboard/api/nova.py
@@ -58,14 +58,6 @@ INSECURE = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
 CACERT = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
 
 
-@memoized
-def get_microversion(request, features):
-    client = novaclient(request)
-    min_ver, max_ver = api_versions._get_server_version_range(client)
-    return (microversions.get_microversion_for_features(
-        'nova', features, api_versions.APIVersion, min_ver, max_ver))
-
-
 def is_feature_available(request, features):
     return bool(get_microversion(request, features))
 
@@ -266,6 +258,33 @@ def get_auth_params_from_request(request):
         base.url_for(request, 'identity')
     )
 
+@memoized_with_request(get_auth_params_from_request)
+def get_microversion(request_auth_params, features):
+    (
+        username,
+        token_id,
+        project_id,
+        project_domain_id,
+        nova_url,
+        auth_url
+    ) = request_auth_params
+    version = VERSIONS.get_active_version()['version']
+    client = nova_client.Client(version,
+                                username,
+                                token_id,
+                                project_id=project_id,
+                                project_domain_id=project_domain_id,
+                                auth_url=auth_url,
+                                insecure=INSECURE,
+                                cacert=CACERT,
+                                http_log_debug=settings.DEBUG,
+                                auth_token=token_id,
+                                endpoint_override=nova_url)
+
+    min_ver, max_ver = api_versions._get_server_version_range(client)
+    return (microversions.get_microversion_for_features(
+        'nova', features, api_versions.APIVersion, min_ver, max_ver))
+
 
 @memoized_with_request(get_auth_params_from_request)
 def novaclient(request_auth_params, version=None):
-- 
2.25.1
openSUSE Build Service is sponsored by