From 02f129b1bb1fc17f17b2fbca43bd997aa8b28d09 Mon Sep 17 00:00:00 2001 From: Amy Fong Date: Fri, 28 Mar 2014 15:58:45 -0400 Subject: 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= 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 Signed-off-by: Bruce Ashfield --- .../fix_cinderclient_memory_leak.patch | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 meta-openstack/recipes-devtools/python/python-cinderclient/fix_cinderclient_memory_leak.patch (limited to 'meta-openstack/recipes-devtools/python/python-cinderclient') diff --git a/meta-openstack/recipes-devtools/python/python-cinderclient/fix_cinderclient_memory_leak.patch b/meta-openstack/recipes-devtools/python/python-cinderclient/fix_cinderclient_memory_leak.patch new file mode 100644 index 0000000..137edfd --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-cinderclient/fix_cinderclient_memory_leak.patch @@ -0,0 +1,37 @@ +--- + cinderclient/openstack/common/apiclient/client.py | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/cinderclient/openstack/common/apiclient/client.py ++++ b/cinderclient/openstack/common/apiclient/client.py +@@ -90,6 +90,7 @@ + self.user_agent = user_agent or self.user_agent + + self.times = [] # [("item", starttime, endtime), ...] ++ self.times_max_len = 200 + self.timings = timings + + # requests within the same session can reuse TCP connections from pool +@@ -142,6 +143,12 @@ + def reset_timings(self): + self.times = [] + ++ def get_timings_max_len(self): ++ return self.times_max_len ++ ++ def set_timings_max_len(self, new_len): ++ self.times_max_len = new_len ++ + def request(self, method, url, **kwargs): + """Send an http request with the specified characteristics. + +@@ -173,6 +180,9 @@ + if self.timings: + self.times.append(("%s %s" % (method, url), + start_time, time.time())) ++ # remove oldest items until we maintain max length ++ while len(self.times) > self.times_max_len: ++ del self.times[0] + self._http_log_resp(resp) + + if resp.status_code >= 400: -- cgit v1.2.3-54-g00ecf