Skip to content

Commit c4fb429

Browse files
authored
Merge pull request #28 from stackhpc/bugfix/memory_leak
Fix memory leak
2 parents 09f29d9 + 3cad01a commit c4fb429

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

os_capacity/prometheus.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,10 @@ def collect(self):
339339
)
340340
skip_host_usage = int(os.environ.get("OS_CAPACITY_SKIP_HOST_USAGE", "0")) == 1
341341

342-
conn = openstack.connect()
343342
openstack.enable_logging(debug=False)
344343
try:
345344
resource_providers, host_guages = get_host_details(
346-
conn.compute, conn.placement
345+
self.conn.compute, self.conn.placement
347346
)
348347
guages += host_guages
349348

@@ -355,7 +354,9 @@ def collect(self):
355354
)
356355

357356
if not skip_project_usage:
358-
guages += get_project_usage(conn.identity, conn.placement, conn.compute)
357+
guages += get_project_usage(
358+
self.conn.identity, self.conn.placement, self.conn.compute
359+
)
359360
project_time = time.perf_counter()
360361
project_duration = project_time - host_time
361362
print(
@@ -366,7 +367,7 @@ def collect(self):
366367
print("2 of 3: skipping project usage")
367368

368369
if not skip_host_usage:
369-
guages += get_host_usage(resource_providers, conn.placement)
370+
guages += get_host_usage(resource_providers, self.conn.placement)
370371
host_usage_time = time.perf_counter()
371372
host_usage_duration = host_usage_time - project_time
372373
print(

0 commit comments

Comments
 (0)