Skip to content

Commit 676fd7e

Browse files
committed
Add handling to metric collect error
As we were simply exiting on metric collect for a scope when any unhandled error happens, other scopes that should be processed after that problematic scope will not be processed, and if the problem persist with this specific scope, it will make CloudKitty to never move on to the next scopes as the processor will stop processing. This proposal is to raise an exception instead of killing the processor when an error happens in the metric collect, so the problematic scope will be skipped till next collection and the other scopes will be processed normally. Story: 2011321 Task: 51519 Change-Id: I460877e818166230014c1d1ae7d9588162554264
1 parent 313ef8b commit 676fd7e

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

cloudkitty/orchestrator.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import hashlib
2121
import multiprocessing
2222
import random
23-
import sys
2423
import time
2524

2625
import cotyledon
@@ -331,7 +330,7 @@ def _get_result(metric):
331330
# collection will be retried during the next collect
332331
# cycle. In the future, we should implement a retrying
333332
# system in workers
334-
sys.exit(1)
333+
raise e
335334

336335
return self._do_execute_collection(_get_result, metrics)
337336

@@ -640,12 +639,19 @@ def internal_run(self):
640639
lock_name=lock_name,
641640
scope_id=tenant_id))
642641

642+
_success = True
643643
try:
644644
self.process_scope(tenant_id)
645+
except Exception as e:
646+
_success = False
647+
LOG.error('Error processing scope %s, we will try it again'
648+
' later.', tenant_id)
649+
LOG.exception(e)
645650
finally:
646651
lock.release()
647652

648-
LOG.debug("Finished processing scope [%s].", tenant_id)
653+
if _success:
654+
LOG.debug("Finished processing scope [%s].", tenant_id)
649655
else:
650656
LOG.debug("Could not acquire lock [%s] for processing "
651657
"scope [%s] with worker [%s].", lock_name,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
fixes:
3+
- |
4+
Changes the metric collector exception handling to raise an exception
5+
instead of killing the processor when an error happens in the metric
6+
collect, so the problematic scope will be skipped till next
7+
collection and the other scopes will be processed normally.

0 commit comments

Comments
 (0)