From ae0a746397cf176750c6a43845d5c6b8189d9f3e Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Thu, 26 Sep 2024 09:34:38 +0900 Subject: [PATCH] feat: modify run last month unified cost parameter by scheduler Signed-off-by: ImMin5 --- .../cost_analysis/service/unified_cost_service.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/spaceone/cost_analysis/service/unified_cost_service.py b/src/spaceone/cost_analysis/service/unified_cost_service.py index 0fcbff47..b465cda4 100644 --- a/src/spaceone/cost_analysis/service/unified_cost_service.py +++ b/src/spaceone/cost_analysis/service/unified_cost_service.py @@ -54,7 +54,8 @@ def run_unified_cost_by_scheduler(self, params: dict) -> None: config_mgr = ConfigManager() current_hour = params["current_hour"] - current_month = datetime.utcnow().strftime("%Y-%m") + current_date = datetime.utcnow() + current_month = current_date.strftime("%Y-%m") identity_mgr = IdentityManager() domain_ids = identity_mgr.list_enabled_domain_ids() @@ -70,7 +71,10 @@ def run_unified_cost_by_scheduler(self, params: dict) -> None: if self._check_unified_cost_job_is_confirmed_with_month( domain_id, current_month ): - self.run_last_month_unified_costs(domain_id, current_month) + last_month = (current_date - relativedelta(months=1)).strftime( + "%Y-%m" + ) + self.run_last_month_unified_costs(domain_id, last_month) except Exception as e: _LOGGER.error(