fix(task): prevent duplicate Slurm job submission on backend restart

RecoverStuckTasks now skips tasks that already have a slurm_job_id,
and ProcessTask adds a guard before the submitting step to prevent
re-submission even if a task is incorrectly re-enqueued.

Also deprecates POST /api/v1/jobs/submit endpoint (replaced by POST /tasks)
and comments out related handlers and tests.
This commit is contained in:
dailz
2026-04-21 10:57:38 +08:00
parent 4fd331ebd8
commit b90942de77
8 changed files with 61 additions and 35 deletions

View File

@@ -49,7 +49,7 @@ func TestAllRoutesRegistered(t *testing.T) {
method string
path string
}{
{"POST", "/api/v1/jobs/submit"},
// {"POST", "/api/v1/jobs/submit"}, // [已弃用] 已被 POST /tasks 取代
{"GET", "/api/v1/jobs"},
{"GET", "/api/v1/jobs/history"},
{"GET", "/api/v1/jobs/1"},
@@ -82,8 +82,8 @@ func TestAllRoutesRegistered(t *testing.T) {
{"GET", "/api/v1/tasks"},
}
if len(routes) != 30 {
t.Fatalf("expected 31 routes, got %d", len(routes))
if len(routes) != 29 {
t.Fatalf("expected 30 routes, got %d", len(routes))
}
for _, r := range routes {