Fix job stop info log print duplicately

Now, when you stop a job whose status is ScheduledState or RunningState,
freezer-scheduler will print the job stop info log many times. In fact,
whatever status the job is in, it is appropriate to print its stop info
log only when it's in StopState status.

Closes-Bug: #1685187
Change-Id: I6efe9ee67980db1d438b051cb718f49935deb23d
This commit is contained in:
howardlee 2017-04-13 04:00:15 -07:00 committed by howard lee
parent bcfe5e2f55
commit 54e955d4b6
1 changed files with 2 additions and 1 deletions

View File

@ -307,7 +307,8 @@ class Job(object):
next_event = job_doc['job_schedule'].get('event', '')
while next_event:
if next_event == Job.STOP_EVENT:
LOG.info('JOB {0} event: STOP'.format(self.id))
if isinstance(self.state(), StopState):
LOG.info('JOB {0} event: STOP'.format(self.id))
next_event = self.state.stop(self, job_doc)
elif next_event == Job.START_EVENT:
LOG.info('JOB {0} event: START'.format(self.id))