Fix decide-after-finish refusal and run size loop data race
A run stays in r.active after finishRunState persists its terminal status until its goroutine finishes notifying, so a decision in that window was refused as "already active". decide now refuses only runs whose terminal state is not yet durable; a finished run gets ResolveDecision's already-decided / not-waiting answer, and an executing run is still refused. Tests overwrote runner.artifactsRoot after Handler/newRunner had started background goroutines (sizeLoop, session export jobs) that read it. The root is now fixed at construction through newRunnerAt, which HandlerWithOptions uses for Options.ArtifactsRoot, and tests configure it there instead of mutating the field afterwards.
This commit is contained in:
@@ -27,9 +27,8 @@ func gateRunner(t *testing.T, export func(context.Context, stage.SessionExportRe
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
h := Handler(ctx, s).(*runHandler)
|
||||
h := HandlerWithOptions(ctx, Options{ArtifactsRoot: t.TempDir()}, s).(*runHandler)
|
||||
t.Cleanup(func() { cancel(); WaitRuns(h); s.Close() })
|
||||
h.runner.artifactsRoot = t.TempDir()
|
||||
h.runner.exportSession = export
|
||||
if _, err := s.Submit(ctx, "gate", pipeline.Template([]string{"one", "two"}, true)); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -352,12 +351,11 @@ func TestSessionExportGateRestartResumesSuccessorNotOwner(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
r, err := newRunner(ctx, reopened)
|
||||
r, err := newRunnerAt(ctx, reopened, root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { cancel(); r.wg.Wait(); r.schedulerWG.Wait(); reopened.Close() }()
|
||||
r.artifactsRoot = root
|
||||
r.exportSession = validGateExport
|
||||
r.execute = func(_ context.Context, def stage.Definition, _ stage.Values) (stage.Result, error) {
|
||||
if def.Key != "two" {
|
||||
|
||||
Reference in New Issue
Block a user