Skip to content

Commit

Permalink
refactor: refacto job close logic
Browse files Browse the repository at this point in the history
  • Loading branch information
whdalsrnt committed Sep 11, 2023
1 parent 21e65c8 commit 480d37f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/spaceone/cost_analysis/service/job_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,24 @@ def _close_job(self, job_id, domain_id, data_source_id):
self._delete_changed_cost_data(job_vo, changed_vo.start, changed_vo.end, changed_vo.filter)

except Exception as e:
_LOGGER.error(f'[_close_job] aggregate cost data error: {e}', exc_info=True)
self._rollback_cost_data(job_vo)
self.job_mgr.change_error_status(job_vo, e)
raise e

self.cost_mgr.remove_stat_cache(domain_id, data_source_id)
try:
self.cost_mgr.remove_stat_cache(domain_id, data_source_id)

if not no_preload_cache:
self.job_mgr.preload_cost_stat_queries(domain_id, data_source_id)
if not no_preload_cache:
self.job_mgr.preload_cost_stat_queries(domain_id, data_source_id)

self.budget_usage_mgr.update_budget_usage(domain_id, data_source_id)
self.budget_usage_mgr.update_budget_usage(domain_id, data_source_id)

self._update_last_sync_time(job_vo)
self.job_mgr.change_success_status(job_vo)
self._update_last_sync_time(job_vo)
self.job_mgr.change_success_status(job_vo)
except Exception as e:
_LOGGER.error(f'[_close_job] cache and budget update error: {e}', exc_info=True)
self.job_mgr.change_error_status(job_vo, e)

elif job_vo.status == 'ERROR':
self._rollback_cost_data(job_vo)
Expand Down

0 comments on commit 480d37f

Please sign in to comment.