Merge remote-tracking branch 'upstream/master'

This commit is contained in:
kunw 2016-07-13 17:24:27 +08:00
commit ea366357e9
2 changed files with 15 additions and 14 deletions

View File

@ -191,6 +191,7 @@ func (sm *SM) Reset(jid int64) error {
sm.desiredState = "" sm.desiredState = ""
sm.lock.Unlock() sm.lock.Unlock()
sm.Logger = utils.NewLogger(sm.JobID)
//init parms //init parms
job, err := dao.GetRepJob(sm.JobID) job, err := dao.GetRepJob(sm.JobID)
if err != nil { if err != nil {
@ -239,7 +240,6 @@ func (sm *SM) Reset(jid int64) error {
sm.Parms.TargetPassword = pwd sm.Parms.TargetPassword = pwd
//init states handlers //init states handlers
sm.Logger = utils.NewLogger(sm.JobID)
sm.Handlers = make(map[string]StateHandler) sm.Handlers = make(map[string]StateHandler)
sm.Transitions = make(map[string]map[string]struct{}) sm.Transitions = make(map[string]map[string]struct{})
sm.CurrentState = models.JobPending sm.CurrentState = models.JobPending

View File

@ -90,8 +90,9 @@ func (w *Worker) handleRepJob(id int64) {
return return
} }
if w.SM.Parms.Enabled == 0 { if w.SM.Parms.Enabled == 0 {
log.Debugf("The policy of job:%d is disabled, will cancel the job") log.Debugf("The policy of job:%d is disabled, will cancel the job", id)
_ = dao.UpdateRepJobStatus(id, models.JobCanceled) _ = dao.UpdateRepJobStatus(id, models.JobCanceled)
w.SM.Logger.Info("The job has been canceled")
} else { } else {
w.SM.Start(models.JobRunning) w.SM.Start(models.JobRunning)
} }