Add run size_bytes and delete_runs to free disk space
Every run summary carries size_bytes (artifact tree, server-created Pi session directories and an estimate of the run's database rows), cached in pipeline_runs.size_bytes, invalidated by triggers, measured when a run finishes and backfilled in the background. delete_runs removes terminal runs with every scoped row and server-owned file, refuses active ones with a reason, and pushes runs_removed to subscribers. pipelines runs rm is the CLI form; retention apply now shares the complete row deletion.
This commit is contained in:
@@ -97,6 +97,11 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
if runErr == nil {
|
||||
runs.schedulerWG.Add(1)
|
||||
go runs.scheduleLoop()
|
||||
// The run-size backfill runs in the background so an upgraded
|
||||
// database never delays startup.
|
||||
runs.sizeKick = make(chan struct{}, 1)
|
||||
runs.schedulerWG.Add(1)
|
||||
go runs.sizeLoop()
|
||||
}
|
||||
}
|
||||
// chat_sessions lists the operator's own recorded sessions. Prefer an
|
||||
@@ -324,9 +329,14 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
response.Error = err.Error()
|
||||
}
|
||||
}
|
||||
} else if runs != nil && (request.Type == protocol.RunPipeline || request.Type == protocol.RetryRun || request.Type == protocol.ListRuns || request.Type == protocol.GetRun || request.Type == protocol.CancelRun || request.Type == protocol.DecideRun || request.Type == protocol.SetRunTitle || request.Type == protocol.GetRunEvidence || request.Type == protocol.RepairSessionExport) {
|
||||
} else if runs != nil && (request.Type == protocol.RunPipeline || request.Type == protocol.RetryRun || request.Type == protocol.ListRuns || request.Type == protocol.GetRun || request.Type == protocol.CancelRun || request.Type == protocol.DecideRun || request.Type == protocol.SetRunTitle || request.Type == protocol.GetRunEvidence || request.Type == protocol.RepairSessionExport || request.Type == protocol.DeleteRuns) {
|
||||
var err error
|
||||
switch request.Type {
|
||||
case protocol.DeleteRuns:
|
||||
// Like cancel and retry, deleting run history is an execution
|
||||
// operation and is not gated by AllowAuthoring.
|
||||
response.Type = protocol.RunsDeleted
|
||||
response.RunsDeleted, err = runs.deleteRuns(request.RunIDs)
|
||||
case protocol.RepairSessionExport:
|
||||
response.Type = protocol.Run
|
||||
response.RunDetail, err = runs.repairSessionExport(ctx, request.RunID, request.ExportSequence)
|
||||
@@ -347,6 +357,7 @@ func HandlerWithOptions(ctx context.Context, options Options, stores ...*pipelin
|
||||
response.RunDetail, err = runs.setTitle(request.RunID, request.Title)
|
||||
case protocol.ListRuns:
|
||||
response.Type = protocol.Runs
|
||||
runs.refreshListSizes(connCtx)
|
||||
response.Runs, err = runs.listRuns()
|
||||
if err == nil {
|
||||
response.Usage, err = stores[0].UsageStats(ctx)
|
||||
|
||||
Reference in New Issue
Block a user