diff --git a/csp_billing_adapter/bill_utils.py b/csp_billing_adapter/bill_utils.py index 6f3c132..2e42d1d 100644 --- a/csp_billing_adapter/bill_utils.py +++ b/csp_billing_adapter/bill_utils.py @@ -665,8 +665,12 @@ def process_metering( 'usage_records': billable_records } - archive_record( - hook, - config, - billing_record - ) + try: + archive_record( + hook, + config, + billing_record + ) + except Exception as error: + # Non-fatal error is only logged + log.exception(error) diff --git a/tests/unit/test_bill_utils.py b/tests/unit/test_bill_utils.py index 416e990..d41b6a3 100644 --- a/tests/unit/test_bill_utils.py +++ b/tests/unit/test_bill_utils.py @@ -801,8 +801,16 @@ def test_create_billing_status(): @mark.config('config_testing_mixed.yaml') +@mock.patch('csp_billing_adapter.bill_utils.archive_record') @mock.patch('csp_billing_adapter.utils.time.sleep') -def test_process_metering_legacy_return(mock_sleep, cba_pm, cba_config): +def test_process_metering_legacy_return( + mock_sleep, + mock_archive, + cba_pm, + cba_config +): + mock_archive.side_effect = Exception('Failed to save archive!') + # initialise the cache create_cache( hook=cba_pm.hook,