runs: reconcile uncertain browser launches with a persistent intent key
This commit is contained in:
@@ -76,6 +76,14 @@ func TestRunWebSocketRemainsResponsiveAndAuditable(t *testing.T) {
|
||||
t.Fatal("started run omitted pinned graph")
|
||||
}
|
||||
<-entered
|
||||
lookup := request(protocol.Message{Type: protocol.GetRun, ID: "reconcile", RequestKey: "ws-once"})
|
||||
if lookup.Type != protocol.Run || lookup.RunDetail == nil || lookup.RunDetail.ID != started.RunDetail.ID {
|
||||
t.Fatalf("read-only admission lookup failed: %+v", lookup)
|
||||
}
|
||||
absent := request(protocol.Message{Type: protocol.GetRun, ID: "absent", RequestKey: "not-admitted"})
|
||||
if absent.Type != protocol.Run || absent.RunDetail != nil {
|
||||
t.Fatalf("absent lookup must not invent a run: %+v", absent)
|
||||
}
|
||||
if response := request(protocol.Message{Type: protocol.Ping, ID: "ping"}); response.Type != protocol.Pong {
|
||||
t.Fatal("active run blocked ping")
|
||||
}
|
||||
|
||||
@@ -302,7 +302,15 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
}
|
||||
case protocol.GetRun:
|
||||
response.Type = protocol.Run
|
||||
response.RunDetail, err = runs.getRun(request.RunID)
|
||||
if request.RunID == 0 && request.RequestKey != "" {
|
||||
var id int64
|
||||
id, err = stores[0].RunByKey(connCtx, request.RequestKey)
|
||||
if err == nil && id != 0 {
|
||||
response.RunDetail, err = runs.getRun(id)
|
||||
}
|
||||
} else {
|
||||
response.RunDetail, err = runs.getRun(request.RunID)
|
||||
}
|
||||
case protocol.CancelRun:
|
||||
response.Type = protocol.Run
|
||||
err = runs.cancel(request.RunID)
|
||||
|
||||
Reference in New Issue
Block a user