Skip to content

Commit

Permalink
feat: modify job "update_at" update & duplicated check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyoungmoonDEV committed Nov 20, 2024
1 parent 425a80f commit 1967243
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions src/spaceone/cost_analysis/manager/job_task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,17 @@ def change_in_progress_status(job_task_vo: JobTask):
{"status": "IN_PROGRESS", "started_at": datetime.utcnow()}
)

@staticmethod
def update_sync_status(job_task_vo: JobTask, created_count: int) -> JobTask:
return job_task_vo.update(
def update_sync_status(self, job_task_vo: JobTask, created_count):
job_task_vo = job_task_vo.update(
{"created_count": job_task_vo.created_count + created_count}
)

def change_success_status(self, job_task_vo: JobTask, created_count: int) -> None:
job_vo = self.job_mgr.get_job(job_task_vo.job_id, job_task_vo.domain_id)
self.job_mgr.update_job_by_vo({}, job_vo)

return job_task_vo

def change_success_status(self, job_task_vo: JobTask, created_count):
_LOGGER.debug(
f"[change_success_status] success job task: {job_task_vo.job_task_id} "
f"(created_count = {created_count})"
Expand All @@ -112,6 +116,7 @@ def change_success_status(self, job_task_vo: JobTask, created_count: int) -> Non

job_vo = self.job_mgr.get_job(job_task_vo.job_id, job_task_vo.domain_id)
self.job_mgr.decrease_remained_tasks(job_vo)
self.job_mgr.update_job_by_vo({}, job_vo)

def change_canceled_status(self, job_task_vo: JobTask) -> None:
_LOGGER.error(
Expand Down
4 changes: 3 additions & 1 deletion src/spaceone/cost_analysis/service/job_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,9 @@ def _check_duplicate_job(
if job_vo.created_at >= duplicate_job_time:
return True
elif job_vo.options.get("sync_mode") == "MANUAL":
return True
manual_duplicate_job_time = datetime.utcnow() - timedelta(hours=24)
if job_vo.updated_at > manual_duplicate_job_time:
return True
else:
self.job_mgr.change_canceled_status(job_vo)

Expand Down

0 comments on commit 1967243

Please sign in to comment.