service: avoid hard pod log dependency for remote jobs

This commit is contained in:
Brad Stein 2026-04-01 12:23:31 -03:00
parent 34dfc165d6
commit 8f0d5389c2

View File

@ -193,16 +193,26 @@ func (a *App) runRemotePod(jobID, podName string, podSpec map[string]any) (strin
if strings.TrimSpace(state.Message) != "" { if strings.TrimSpace(state.Message) != "" {
return strings.TrimSpace(state.Message), nil return strings.TrimSpace(state.Message), nil
} }
return a.remotePodLogs(kube, podName) logs, logErr := a.remotePodLogs(kube, podName)
if strings.TrimSpace(logs) != "" {
return strings.TrimSpace(logs), nil
}
if logErr != nil {
return "", fmt.Errorf("remote pod %s succeeded but did not return a result payload; logs unavailable: %v", podName, logErr)
}
return "", fmt.Errorf("remote pod %s succeeded but did not return a result payload", podName)
case "Failed": case "Failed":
if strings.TrimSpace(state.Message) != "" { if strings.TrimSpace(state.Message) != "" {
return "", fmt.Errorf("remote pod %s failed: %s", podName, strings.TrimSpace(state.Message)) return "", fmt.Errorf("remote pod %s failed: %s", podName, strings.TrimSpace(state.Message))
} }
logs, _ := a.remotePodLogs(kube, podName) if logs, logErr := a.remotePodLogs(kube, podName); logErr == nil && strings.TrimSpace(logs) != "" {
if strings.TrimSpace(logs) != "" {
return "", fmt.Errorf("remote pod %s failed: %s", podName, strings.TrimSpace(logs)) return "", fmt.Errorf("remote pod %s failed: %s", podName, strings.TrimSpace(logs))
} }
return "", fmt.Errorf("remote pod %s failed: %s %s", podName, state.Reason, state.Message) reason := strings.TrimSpace(state.Reason)
if reason == "" {
reason = "remote worker failed before reporting details"
}
return "", fmt.Errorf("remote pod %s failed: %s", podName, reason)
} }
time.Sleep(2 * time.Second) time.Sleep(2 * time.Second)
} }