diff --git a/job/statemachine.go b/job/statemachine.go index 95b306033..95b242740 100644 --- a/job/statemachine.go +++ b/job/statemachine.go @@ -191,6 +191,7 @@ func (sm *SM) Reset(jid int64) error { sm.desiredState = "" sm.lock.Unlock() + sm.Logger = utils.NewLogger(sm.JobID) //init parms job, err := dao.GetRepJob(sm.JobID) if err != nil { @@ -239,7 +240,6 @@ func (sm *SM) Reset(jid int64) error { sm.Parms.TargetPassword = pwd //init states handlers - sm.Logger = utils.NewLogger(sm.JobID) sm.Handlers = make(map[string]StateHandler) sm.Transitions = make(map[string]map[string]struct{}) sm.CurrentState = models.JobPending diff --git a/job/workerpool.go b/job/workerpool.go index c01273ba3..41211d9de 100644 --- a/job/workerpool.go +++ b/job/workerpool.go @@ -1,16 +1,16 @@ /* - Copyright (c) 2016 VMware, Inc. All Rights Reserved. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. */ package job @@ -90,8 +90,9 @@ func (w *Worker) handleRepJob(id int64) { return } 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) + w.SM.Logger.Info("The job has been canceled") } else { w.SM.Start(models.JobRunning) }