Runs: one uninterruptible stage session no longer disables the runner
Start-up recovery used to fail the whole runner when any previously active stage session could not be confirmed stopped. That run alone is now marked interrupted with a diagnostic naming the session and error. A Pi owner whose process and process group are gone counts as stopped without its quiescence receipt (it crashed), as the Claude stage path already did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -194,6 +194,40 @@ func TestStageRunWithHarnessGoneFallsBackWithReason(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestUninterruptibleStageSessionInterruptsOnlyItsRun: one stage session that
|
||||
// start-up cannot confirm stopped (a crashed Pi owner, a missing Claude
|
||||
// evidence directory) used to fail the whole runner, disabling every run.
|
||||
// Now only its run is interrupted, naming why, and the runner starts.
|
||||
func TestUninterruptibleStageSessionInterruptsOnlyItsRun(t *testing.T) {
|
||||
seamRestartRecovery(t, nil)
|
||||
interruptRecoveredSession = func(context.Context, pipeline.SessionOwner) error {
|
||||
return fmt.Errorf("retained Pi owner: %w", stage.ErrStageCleanup)
|
||||
}
|
||||
f := stopMidStage(t, func(ctx context.Context, s *pipeline.Store, id int64) (stage.Result, error) {
|
||||
if err := s.RunSession(context.Background(), id, 1, "ses_pi", true, "pi", "/nonexistent/pi-ref"); err != nil {
|
||||
return stage.Result{}, err
|
||||
}
|
||||
<-ctx.Done()
|
||||
return stage.Result{}, stage.ErrDetached
|
||||
})
|
||||
r, s := f.restart(t, func(context.Context, *pipeline.Store, stage.Definition) (stage.Result, error) {
|
||||
t.Error("an interrupted run executed again")
|
||||
return stage.Result{}, nil
|
||||
})
|
||||
r.reattachRuns()
|
||||
r.wg.Wait()
|
||||
d, err := s.GetRun(context.Background(), f.runID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if d.Status != "interrupted" || !strings.Contains(d.Diagnostic, "could not be confirmed stopped") || !strings.Contains(d.Diagnostic, "ses_pi") {
|
||||
t.Fatalf("uninterruptible session's run lacks a clear reason: status=%s run=%q", d.Status, d.Diagnostic)
|
||||
}
|
||||
if owners, _ := s.ActiveSessionOwners(context.Background()); len(owners) != 0 {
|
||||
t.Fatalf("the interrupted run's session still blocks recovery at the next start: %+v", owners)
|
||||
}
|
||||
}
|
||||
|
||||
// TestStageNotYetAdmittedStartsAgainAfterRestart: a visit the stopped server
|
||||
// had begun but not handed to any session is started again, nothing replayed.
|
||||
func TestStageNotYetAdmittedStartsAgainAfterRestart(t *testing.T) {
|
||||
|
||||
@@ -152,7 +152,15 @@ func newRunnerReattaching(ctx context.Context, s *pipeline.Store, artifactsRoot
|
||||
cancel()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot interrupt previously active agent %s: %w", owner.ID, err)
|
||||
// One session that cannot be confirmed stopped must not disable
|
||||
// every run: interrupt only its run, saying why, and go on.
|
||||
reason := fmt.Sprintf("its previous %s stage agent (session %s) could not be confirmed stopped (%v); check for a leftover agent process before reusing the workspace", owner.Backend, owner.ID, err)
|
||||
if prior := reasons[owner.RunID]; prior != "" {
|
||||
reason = prior + "; " + reason
|
||||
}
|
||||
reasons[owner.RunID] = reason
|
||||
log.Printf("run %d: cannot interrupt previously active agent %s: %v; the run is marked interrupted", owner.RunID, owner.ID, err)
|
||||
continue
|
||||
}
|
||||
if err := s.ConfirmRecoveredSession(ctx, owner); err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user