Skip to content

Commit a0238b3

Browse files
author
Jongmin Kim
authored
Merge pull request #23 from whdalsrnt/master
chore: change debug messages
2 parents e0d9a8e + 7b2e45c commit a0238b3

File tree

1 file changed

+31
-26
lines changed

1 file changed

+31
-26
lines changed

src/spaceone/statistics/interface/task/stat_hourly_scheduler.py

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def create_task(self):
2727
result = []
2828
for domain_info in self.list_domains():
2929
stp = self._create_job_request(domain_info["domain_id"], current_hour)
30-
result.append(stp)
30+
if stp is not None:
31+
result.append(stp)
3132
return result
3233

3334
def list_domains(self):
@@ -58,31 +59,35 @@ def _list_schedule(self, domain_id: str, current_hour: int):
5859
return schedules
5960

6061
def _create_job_request(self, domain_id: str, current_hour: int):
61-
_LOGGER.debug(f"[_create_job_request] domain: {domain_id}")
6262
schedules = self._list_schedule(domain_id, current_hour)
63-
schedule_jobs = []
64-
for schedule in schedules:
65-
job = {
66-
"locator": "SERVICE",
67-
"name": "HistoryService",
68-
"metadata": {
69-
"token": self._token,
70-
},
71-
"method": "create",
72-
"params": {
63+
schedule_count = len(schedules)
64+
if schedule_count > 0:
65+
_LOGGER.debug(f"[_create_job_request] {domain_id}: {len(schedules)}")
66+
67+
schedule_jobs = []
68+
for schedule in schedules:
69+
job = {
70+
"locator": "SERVICE",
71+
"name": "HistoryService",
72+
"metadata": {
73+
"token": self._token,
74+
},
75+
"method": "create",
7376
"params": {
74-
"schedule_id": schedule.schedule_id,
75-
"domain_id": domain_id,
76-
}
77-
},
78-
}
79-
schedule_jobs.append(job)
77+
"params": {
78+
"schedule_id": schedule.schedule_id,
79+
"domain_id": domain_id,
80+
}
81+
},
82+
}
83+
schedule_jobs.append(job)
8084

81-
stp = {
82-
"name": "statistics_hourly_schedule",
83-
"version": "v1",
84-
"executionEngine": "BaseWorker",
85-
"stages": schedule_jobs,
86-
}
87-
_LOGGER.debug(f"[_create_job_request] tasks: {stp}")
88-
return stp
85+
stp = {
86+
"name": "statistics_hourly_schedule",
87+
"version": "v1",
88+
"executionEngine": "BaseWorker",
89+
"stages": schedule_jobs,
90+
}
91+
return stp
92+
else:
93+
return None

0 commit comments

Comments
 (0)