fix: logs io buffer combine
This commit is contained in:
@@ -211,6 +211,7 @@ func (h *ServerSchedulerHandler) OnTaskCompleted(req *executor.ExecutionRequest,
|
||||
TaskID: task.ID,
|
||||
Command: req.Command,
|
||||
Output: output,
|
||||
Error: result.Error,
|
||||
Status: result.Status,
|
||||
Duration: result.Duration,
|
||||
ExitCode: result.ExitCode,
|
||||
@@ -262,13 +263,16 @@ func (h *ServerSchedulerHandler) OnTaskFailed(req *executor.ExecutionRequest, er
|
||||
|
||||
now := models.LocalTime(time.Now())
|
||||
taskLog := &models.TaskLog{
|
||||
ID: req.LogID,
|
||||
TaskID: taskID,
|
||||
Output: output,
|
||||
Status: "failed",
|
||||
Duration: 0,
|
||||
ExitCode: 1,
|
||||
EndTime: &now,
|
||||
ID: req.LogID,
|
||||
TaskID: taskID,
|
||||
Command: req.Command,
|
||||
Output: output,
|
||||
Error: err.Error(),
|
||||
Status: "failed",
|
||||
Duration: 0,
|
||||
ExitCode: 1,
|
||||
StartTime: &now,
|
||||
EndTime: &now,
|
||||
}
|
||||
|
||||
// 补充 AgentID
|
||||
@@ -645,6 +649,7 @@ func (es *ExecutorService) ExecuteRemoteForScheduler(task *models.Task, logID ui
|
||||
case agentResult := <-resultChan:
|
||||
return &executor.Result{
|
||||
Output: agentResult.Output,
|
||||
Error: agentResult.Error,
|
||||
Status: agentResult.Status,
|
||||
Duration: agentResult.Duration,
|
||||
ExitCode: agentResult.ExitCode,
|
||||
@@ -655,11 +660,12 @@ func (es *ExecutorService) ExecuteRemoteForScheduler(task *models.Task, logID ui
|
||||
end := time.Now()
|
||||
return &executor.Result{
|
||||
Status: "failed",
|
||||
Error: "等待 Agent 结果超时",
|
||||
Duration: end.Sub(start).Milliseconds(),
|
||||
ExitCode: -1,
|
||||
StartTime: start,
|
||||
EndTime: end,
|
||||
}, fmt.Errorf("远程执行超时")
|
||||
}, fmt.Errorf("等待 Agent 结果超时")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,6 +156,7 @@ func (s *TaskLogService) CreateTaskLogFromAgentResult(result *models.AgentTaskRe
|
||||
AgentID: &result.AgentID,
|
||||
Command: result.Command,
|
||||
Output: compressed,
|
||||
Error: result.Error,
|
||||
Status: result.Status,
|
||||
Duration: result.Duration,
|
||||
ExitCode: result.ExitCode,
|
||||
@@ -175,7 +176,7 @@ func (s *TaskLogService) CreateTaskLogFromAgentResult(result *models.AgentTaskRe
|
||||
}
|
||||
|
||||
// CreateTaskLogFromLocalExecution 从本地执行结果创建任务日志
|
||||
func (s *TaskLogService) CreateTaskLogFromLocalExecution(taskID uint, command, output, status string, duration int64, exitCode int, start, end time.Time, isCompressed bool) (*models.TaskLog, error) {
|
||||
func (s *TaskLogService) CreateTaskLogFromLocalExecution(taskID uint, command, output, systemErr, status string, duration int64, exitCode int, start, end time.Time, isCompressed bool) (*models.TaskLog, error) {
|
||||
var compressed string
|
||||
var err error
|
||||
|
||||
@@ -197,6 +198,7 @@ func (s *TaskLogService) CreateTaskLogFromLocalExecution(taskID uint, command, o
|
||||
TaskID: taskID,
|
||||
Command: command,
|
||||
Output: compressed,
|
||||
Error: systemErr,
|
||||
Status: status,
|
||||
Duration: duration,
|
||||
ExitCode: exitCode,
|
||||
|
||||
Reference in New Issue
Block a user