Expose storage usage and safe persisted age or size retention
This commit is contained in:
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
@@ -103,8 +104,19 @@ func (r *runner) finishedSize(id int64) int64 {
|
||||
// then tells every subscribed client which runs are gone. It holds r.mu so a run
|
||||
// cannot become active between the executing check and the delete.
|
||||
func (r *runner) deleteRuns(ids []int64) (*protocol.RunsDeletedResult, error) {
|
||||
r.mu.Lock()
|
||||
result, err := r.store.DeleteRuns(r.ctx, ids, r.artifactsRoot, func(id int64) string {
|
||||
return r.deleteRunsContext(r.ctx, ids, false)
|
||||
}
|
||||
|
||||
// Storage maintenance uses its own deadline and never queues behind execution.
|
||||
func (r *runner) deleteRunsContext(ctx context.Context, ids []int64, try bool) (*protocol.RunsDeletedResult, error) {
|
||||
if try {
|
||||
if !r.mu.TryLock() {
|
||||
return nil, fmt.Errorf("run maintenance is busy; retry shortly")
|
||||
}
|
||||
} else {
|
||||
r.mu.Lock()
|
||||
}
|
||||
result, err := r.store.DeleteRuns(ctx, ids, r.artifactsRoot, func(id int64) string {
|
||||
if _, ok := r.active[id]; ok {
|
||||
return "run is executing"
|
||||
}
|
||||
@@ -126,7 +138,7 @@ func (r *runner) deleteRuns(ids []int64) (*protocol.RunsDeletedResult, error) {
|
||||
r.notifyMu.Unlock()
|
||||
// A deleted run's notifications are gone on every device.
|
||||
if r.notes != nil {
|
||||
c, cancel := context.WithTimeout(r.ctx, 5*time.Second)
|
||||
c, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
r.notes.clearFor(c, pipeline.AppNotificationFilter{RunID: id})
|
||||
cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user