Add recovery for orphaned jobs
This commit is contained in:
+13
-1
@@ -276,7 +276,8 @@ func (d *dispatcher) handle(ctx context.Context, env api.Envelope, tx wsclient.S
|
||||
if err := env.UnmarshalPayload(&p); err != nil {
|
||||
return fmt.Errorf("command.cancel: %w", err)
|
||||
}
|
||||
if d.cancelJob(p.JobID) {
|
||||
known := d.cancelJob(p.JobID)
|
||||
if known {
|
||||
slog.Info("ws agent: command.cancel applied", "job_id", p.JobID)
|
||||
} else {
|
||||
// Job already finished or was never seen on this agent.
|
||||
@@ -284,6 +285,17 @@ func (d *dispatcher) handle(ctx context.Context, env api.Envelope, tx wsclient.S
|
||||
// natural completion. Server-side state is authoritative.
|
||||
slog.Info("ws agent: command.cancel for unknown job (already finished?)", "job_id", p.JobID)
|
||||
}
|
||||
result := api.CommandResultPayload{JobID: p.JobID, Accepted: known}
|
||||
if !known {
|
||||
result.Error = "job_not_found"
|
||||
}
|
||||
ack, err := api.Marshal(api.MsgCommandResult, env.ID, result)
|
||||
if err != nil {
|
||||
return fmt.Errorf("command.cancel result: %w", err)
|
||||
}
|
||||
if err := tx.Send(ack); err != nil {
|
||||
return fmt.Errorf("command.cancel result send: %w", err)
|
||||
}
|
||||
|
||||
case api.MsgTreeList:
|
||||
// Synchronous RPC for the restore wizard's tree browser. The
|
||||
|
||||
Reference in New Issue
Block a user