Example #1
0
// we will check output file, if content contain msg_filter, we will change status to Failed
func (agent *Agent) HandleStatusSuccess(s *TaskStatus) {
	agent.Lock.Lock()
	defer agent.Lock.Unlock()
	if !util.HitFilter(s.TaskPtr.LogFilename, s.TaskPtr.Job.MsgFilter) {
		s.TaskPtr.Job.LastSuccessAt = s.CreateAt
		s.TaskPtr.Job.LastTaskId = s.TaskPtr.TaskId
		if agent.Running[s.TaskPtr.JobId].Status == StatusTimeout {
			s.TaskPtr.Job.LastStatus = JobTimeout
		} else {
			s.TaskPtr.Job.LastStatus = JobSuccess
		}
		delete(agent.Process, s.TaskPtr.TaskId)
		delete(agent.Running, s.TaskPtr.JobId)
		s.TaskPtr.Job.SuccessCnt += 1

		log.Warning("Task success : ", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.TaskPtr.ExecDuration)
	} else {
		s.TaskPtr.Job.LastErrAt = s.CreateAt
		s.TaskPtr.Job.LastTaskId = s.TaskPtr.TaskId
		s.TaskPtr.Job.LastStatus = JobFail
		s.Status = StatusFailed
		delete(agent.Process, s.TaskPtr.TaskId)
		delete(agent.Running, s.TaskPtr.JobId)
		s.TaskPtr.Job.ErrCnt += 1
		log.Warningf("Task failed : hit msg_filter error", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.TaskPtr.ExecDuration)
		s.Err = errors.New(fmt.Sprintf("Task: %s  Job: %s failed.  hit msg_filter error", s.TaskPtr.TaskId, s.TaskPtr.Job.Name))
	}
	s.Message = util.GetFileContent(s.TaskPtr.LogFilename, 65535, 1)
	if ok := agent.store.UpdateTaskStatus(s); !ok {
		log.Warning("Task status Store Or Update failed ", s)
	}
	agent.PostTaskStatus(s)
}
Example #2
0
func (agent *Agent) HandleStatusKilled(s *TaskStatus) {
	agent.Lock.Lock()
	defer agent.Lock.Unlock()
	delete(agent.Process, s.TaskPtr.TaskId)
	delete(agent.Running, s.TaskPtr.JobId)
	s.TaskPtr.Job.LastErrAt = s.CreateAt
	s.TaskPtr.Job.LastTaskId = s.TaskPtr.TaskId
	s.TaskPtr.Job.LastStatus = JobKilled
	s.TaskPtr.Job.ErrCnt += 1
	log.Warning("Task Killed : ", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.Err.Error())
	s.Err = errors.New(fmt.Sprintf("Task: %s Job: %s killed %s", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.Err.Error()))
	s.Message = util.GetFileContent(s.TaskPtr.LogFilename, 65535, 1)
	if ok := agent.store.UpdateTaskStatus(s); !ok {
		log.Warning("Task status Store Or Update failed ", s)
	}
	agent.PostTaskStatus(s)
}
Example #3
0
func (agent *Agent) HandleStatusTimeout(s *TaskStatus) {
	agent.Lock.Lock()
	defer agent.Lock.Unlock()
	if s.TaskPtr.Job.OnTimeout() == TriggerKill {
		delete(agent.Process, s.TaskPtr.TaskId)
	}
	agent.Running[s.TaskPtr.JobId].Status = StatusTimeout
	s.TaskPtr.Job.LastErrAt = s.CreateAt
	s.TaskPtr.Job.LastTaskId = s.TaskPtr.TaskId
	s.TaskPtr.Job.TimeoutCnt += 1
	log.Warning("Task timeout : ", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.Err.Error())
	s.Err = errors.New(fmt.Sprintf("Task: %s Job: %s timeout %s", s.TaskPtr.TaskId, s.TaskPtr.Job.Name, s.Err.Error()))
	s.Message = util.GetFileContent(s.TaskPtr.LogFilename, 65535, 1)
	if ok := agent.store.UpdateTaskStatus(s); !ok {
		log.Warning("Task status Store Or Update failed ", s)
	}
	agent.PostTaskStatus(s)
}