summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-novaclient
diff options
context:
space:
mode:
authorAmy Fong <amy.fong@windriver.com>2014-03-28 15:58:45 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-03-31 13:14:49 -0400
commit02f129b1bb1fc17f17b2fbca43bd997aa8b28d09 (patch)
treea125ec774f2054684ddd364aeb6caceb8c1bf637 /meta-openstack/recipes-devtools/python/python-novaclient
parent984c2d69f51824a4c1e7b3a448fe24759e594026 (diff)
downloadmeta-cloud-services-02f129b1bb1fc17f17b2fbca43bd997aa8b28d09.tar.gz
Memory leak from timings
Memory leak happens when the dynamic list times grows without anything to reset it. In ceilometer and cinder configuration files, the new option is created: [nova_client] max_timing_buffer=<value> In all clients found that uses extends the HTTPClient and uses the times list, we limit the size of the list by popping off the oldest item in the list to maintain a maximum size. A default size of 200 is chosen, configurable by the above configuration option. Signed-off-by: Amy Fong <amy.fong@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-novaclient')
-rw-r--r--meta-openstack/recipes-devtools/python/python-novaclient/fix_novaclient_memory_leak.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-novaclient/fix_novaclient_memory_leak.patch b/meta-openstack/recipes-devtools/python/python-novaclient/fix_novaclient_memory_leak.patch
new file mode 100644
index 0000000..5732d9a
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-novaclient/fix_novaclient_memory_leak.patch
@@ -0,0 +1,103 @@
1---
2 novaclient/client.py | 10 ++++++++++
3 novaclient/openstack/common/apiclient/client.py | 10 ++++++++++
4 novaclient/v1_1/client.py | 6 ++++++
5 novaclient/v3/client.py | 6 ++++++
6 4 files changed, 32 insertions(+)
7
8--- a/novaclient/client.py
9+++ b/novaclient/client.py
10@@ -87,6 +87,7 @@
11 self.timeout = None
12
13 self.times = [] # [("item", starttime, endtime), ...]
14+ self.times_max_len = 200
15
16 self.management_url = self.bypass_url or None
17 self.auth_token = auth_token
18@@ -139,6 +140,12 @@
19 def reset_timings(self):
20 self.times = []
21
22+ def get_timings_max_len(self):
23+ return self.times_max_len
24+
25+ def set_timings_max_len(self, new_len):
26+ self.times_max_len = new_len
27+
28 def http_log_req(self, method, url, kwargs):
29 if not self.http_log_debug:
30 return
31@@ -214,6 +221,9 @@
32 resp, body = self.request(url, method, **kwargs)
33 self.times.append(("%s %s" % (method, url),
34 start_time, time.time()))
35+ # remove oldest items until we maintain max length
36+ while len(self.times) > self.times_max_len:
37+ del self.times[0]
38 return resp, body
39
40 def _cs_request(self, url, method, **kwargs):
41--- a/novaclient/openstack/common/apiclient/client.py
42+++ b/novaclient/openstack/common/apiclient/client.py
43@@ -90,6 +90,7 @@
44 self.user_agent = user_agent or self.user_agent
45
46 self.times = [] # [("item", starttime, endtime), ...]
47+ self.times_max_len = 200
48 self.timings = timings
49
50 # requests within the same session can reuse TCP connections from pool
51@@ -142,6 +143,12 @@
52 def reset_timings(self):
53 self.times = []
54
55+ def get_timings_max_len(self):
56+ return self.times_max_len
57+
58+ def set_timings_max_len(self, new_len):
59+ self.times_max_len = new_len
60+
61 def request(self, method, url, **kwargs):
62 """Send an http request with the specified characteristics.
63
64@@ -173,6 +180,9 @@
65 if self.timings:
66 self.times.append(("%s %s" % (method, url),
67 start_time, time.time()))
68+ # remove oldest items until we maintain max length
69+ while len(self.times) > self.times_max_len:
70+ del self.times[0]
71 self._http_log_resp(resp)
72
73 if resp.status_code >= 400:
74--- a/novaclient/v1_1/client.py
75+++ b/novaclient/v1_1/client.py
76@@ -156,6 +156,12 @@
77 def reset_timings(self):
78 self.client.reset_timings()
79
80+ def get_timings_max_len(self):
81+ return self.client.get_timings_max_len()
82+
83+ def set_timings_max_len(self, new_len):
84+ self.client.set_timings_max_len(new_len)
85+
86 def authenticate(self):
87 """
88 Authenticate against the server.
89--- a/novaclient/v3/client.py
90+++ b/novaclient/v3/client.py
91@@ -121,6 +121,12 @@
92 def reset_timings(self):
93 self.client.reset_timings()
94
95+ def get_timings_max_len(self):
96+ return self.client.get_timings_max_len()
97+
98+ def set_timings_max_len(self, new_len):
99+ self.client.set_timings_max_len(new_len)
100+
101 def authenticate(self):
102 """
103 Authenticate against the server.