revert: remove config_apply retry (500 is fatal)
500 是 agent 端 media-server reload 超时导致的致命错误, 不应在 managerd 端重试。根因在 agent 的 10s 超时过短。
This commit is contained in:
parent
f2b3941e4a
commit
ea955eb265
@ -9,7 +9,6 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"3588AdminBackend/internal/config"
|
||||
"3588AdminBackend/internal/models"
|
||||
@ -308,26 +307,13 @@ func (s *TaskService) executeOnDevice(task *models.Task, did string) {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, "invalid payload: "+err.Error())
|
||||
return
|
||||
}
|
||||
// Retry config apply up to 3 times (media-server may be slow to reload).
|
||||
var lastErr error
|
||||
var lastCode int
|
||||
for attempt := 0; attempt < 3; attempt++ {
|
||||
if attempt > 0 {
|
||||
time.Sleep(time.Duration(attempt) * 3 * time.Second)
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskRunning, float64(attempt)/3.0, fmt.Sprintf("重试 %d/2", attempt))
|
||||
}
|
||||
_, code, err := s.agent.Do("PUT", dev.IP, dev.AgentPort, "/v1/config", body)
|
||||
if err == nil && code < 400 {
|
||||
lastErr = nil; lastCode = code; break
|
||||
}
|
||||
lastErr = err; lastCode = code
|
||||
}
|
||||
if lastErr != nil {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, lastErr.Error())
|
||||
_, code, err := s.agent.Do("PUT", dev.IP, dev.AgentPort, "/v1/config", body)
|
||||
if err != nil {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, err.Error())
|
||||
return
|
||||
}
|
||||
if lastCode >= 400 {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, fmt.Sprintf("agent error: %d", lastCode))
|
||||
if code >= 400 {
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskFailed, 0, fmt.Sprintf("agent error: %d", code))
|
||||
return
|
||||
}
|
||||
s.updateDeviceStatus(task.ID, did, models.TaskSuccess, 1.0, "")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user