carlos / platform Public

Raise analytics prune limits and report unfinished passes

Allow up to two million deletions within the existing ten-minute deadline. Warn and fail the economics job when a pass leaves progress to resume, with tests for fleet throughput, both caps and timeout recovery.

Clarify that the IAM wildcard spans path separators and the prune guard enforces the exact day-file boundary.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 51e7dcd35590b801dc23862c901b312b6634e7f4 parent 1e48254
4 files changed, +241 −10
  • infra/modules/region-host/main.tf +7 −5
  • infra/modules/region-host/variables.tf +1 −1
  • internal/console/analyticsprune.go +23 −4
  • internal/console/analyticsprune_versions_test.go +210 −0

Intent

Human

<task-notification> <task-id>a15a2482578e9726d</task-id> <tool-use-id>toolu_01RFNmRXVL4AxDU7WPwK5zMN</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/dbc12c58-9d65-48e0-ba5b-f12ec7bb5a4d/tasks/a15a2482578e9726d.output</output-file> <status>completed</status> <summary>Agent "Opus census verdict" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>All four units and all four re-pinned envelopes are approved. The verdict is saved in /home/paulca/.cache/stats-prune/census-verdict.md and has not been posted anywhere. The sandbox blocked writes to `~/.cache`, so I wrote that one file with the sandbox disabled. Census verdict, stats-prune-400 @ 1e482544, reviewer Opus 5.5 infra/modules/region-host/main.tf (external): APPROVE — the new host_analytics_prune policy is count 0 unless enable_analytics_version_prune is set, and group mode refuses that input; when on, it adds only s3:ListBucketVersions (s3:prefix apps/*) and s3:DeleteObjectVersion on apps/\*/\*/analytics/\*/days/\* to the host role, which already has Put/DeleteObject on the whole deployment bucket and no deployment-bucket version read; no read is added, no existing grant, Deny, release-key Deny or group refusal is weakened, and BoxRecordsAreNeverDeleted still denies DeleteObjectVersion on the evidence prefixes (note: IAM * spans "/", so the pattern can also match deeper apps/ keys containing /analytics/.../days/, but only the box role's holder can use it and it adds no root read). infra/modules/region-host/variables.tf (external): APPROVE — adds one operator Terraform bool, enable_analytics_version_prune, default false; no box runtime read and no existing validation touched. infra/modules/region-host/tests/group.tftest.hcl (external): APPROVE — adds one mock plan run that expects group mode to refuse enable_analytics_version_prune; test-only, no runtime reads. infra/modules/region-host/tests/analytics_prune.tftest.hcl (external, new; legacy, accepted-legacy, frozen): APPROVE — mock-provider plan assertions only: off by default, the exact two-statement policy when on, nothing on the data bucket, and host_buckets unchanged; no AWS effect and nothing on a box reads it. envelope infra/modules/region-host: APPROVE — the only changes are the counted prune policy, its variable and the added group-mode refusal clause, all covered by the units above; the group precondition is strengthened, not loosened. envelope infra/modules/region-host/tests: APPROVE — one new mock test file and one new expect_failures run; both are test-only Terraform with no runtime reads. envelope internal/analytics: APPROVE — the only non-test change is the new prune.go (Prune, RetentionCutoff, pruneChild, pruneEligible); its one caller is the console (internal/console/analyticsprune.go, out of the root binary), it has no init or package state, and it deletes only exact YYYY-MM-DD.json leaves under a validated BoxPrefix, so root gains no open, run, query or follow. envelope internal/release: APPROVE — new optional S3Store/DirStore capabilities (BatchDeleter/DeleteKeys, VersionPager, VersionDeleter, VersionDirLister, CountedDirLister) are reached only from analytics.Prune; nothing in the root binary type-asserts or calls them, and S3Store.ListDirs now wraps ListDirsWithCount with the same paginator, delimiter and output, only adding a request count.</result> <usage><subagent_tokens>81722</subagent_tokens><tool_uses>11</tool_uses><duration_ms>101630</duration_ms></usage> </task-notification>

Human

<task-notification> <task-id>a85041e090a364eeb</task-id> <tool-use-id>toolu_01Q1b2iZRHX2FHGf6kVAxpMn</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/dbc12c58-9d65-48e0-ba5b-f12ec7bb5a4d/tasks/a85041e090a364eeb.output</output-file> <status>completed</status> <summary>Agent "Opus storage-gate review" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Verdict: READY AFTER FIXES.** There is one P1, and it depends on fleet size: the daily delete cap is smaller than the rate at which old versions build up. Nothing can delete anything it shouldn't. I made no repo changes, and the targeted tests pass (analytics, release, console). **What holds** 1. **Scope:** every delete goes through one check, `internal/analytics/prune.go:289-300`, and all three delete paths only receive keys that passed it. That covers deleting versions, batch deletes and single-key deletes. - The days prefix is rebuilt from validated account, app and box names, never from a listed string. `..`, `.`, slashes and empty names are refused. - The check needs that exact prefix plus a 15-character `YYYY-MM-DD.json` name whose date parses and formats back the same. That rules out nested keys, neighbouring trees, an app named analytics and a box named days. - The resume cursor is only used to skip ahead and never reaches a delete. The access-denied fallback goes back through the same check. - `DeleteVersions` (`objectversions.go:254`) refuses an empty version id, so a key can't be deleted without one in version mode. - The console's store is a plain `*S3Store`; the timing wrapper only swaps the HTTP client, so no wrapper can skip the check. 2. **Date rule:** the cutoff is today's UTC midnight minus N days. A file dated exactly N days ago is kept; N+1 is deleted. Very large N is clamped safely. A badly named day file is logged and skipped, and it never ends a box's scan early. 3. **Versions:** both S3 listing markers are passed back unchanged, and every continuation is checked. Delete markers are deleted too, and `null` version ids are accepted. Batches are at most 1,000, and per-version errors are tied to the right version. Deleting each page before fetching the next is the same pattern boto3 uses to empty versioned buckets. 4. **Cost:** there is no per-box polling. Each daily pass makes one LIST per account and per app, and a few LISTs per box, with deletes batched. The once-a-day check is stored in the console database and survives restarts. 5. **IAM:** the grant only exists when the variable is on (default off) and is refused in group mode. It covers listing versions under `apps/*` and deleting versions under `apps/*/*/analytics/*/days/*`. Existing grants and the bucket's evidence Deny are unchanged. 6. **Settings:** unset retention returns before any database or bucket work. Zero, negative, non-integer or a bad dry-run value stops the console at startup. **Findings** - **P1-1 (`internal/console/analyticsprune.go:68`, cap enforced in `prune.go:203,279,388`):** a pass deletes at most 10,000 versions. The deployment bucket keeps versions and nothing expires old ones under `apps/` (`deployment-buckets/main.tf:23`). Each app's day file is rewritten every 5 minutes while it has traffic, and bot hits count (`usage_loop.go:82`), so a busy app on one box leaves about 288 versions per day. - One pass can therefore clear only about 34 busy app-box pairs a day. Above that, old files stay forever and the 400-day promise fails. The only sign is a non-empty `next_box` in the log, with no alert. - Fix: raise the cap a lot (S3 DELETE requests are free) and let the 10-minute deadline be the real limit, or keep looping while time remains. Flag a pass that ends with a backlog as a warning or alert. Add a test with about 288 versions per box-day across more than 35 boxes. - **P3-1 (`infra/modules/region-host/main.tf:476`, comment at :449-459, `variables.tf:210`):** in IAM, `*` also matches `/`. So the delete grant covers any key under `apps/` with `/analytics/` and then `/days/` at any depth, not "exactly the day files" as the comment and variable description say. The code check is the real limit; reword the comment. - **P3-2 (`prune.go:91-94`):** without the IAM variable, every pass deletes only the current key and leaves the old versions. It logs a permission error and marks the economics job failed. Before Carloku sets 400, confirm the role that actually runs the flagship console has the grant, because that role may be managed outside this repo. - **P3-3 (`prune.go:245-254`):** one bad listing page ends the whole pass rather than skipping that box. It fails safe, but every later box waits a day. The implementer's four known P3s are confirmed and not repeated. Findings are written to /home/paulca/.cache/stats-prune/review-storage-findings.md.</result> <usage><subagent_tokens>111264</subagent_tokens><tool_uses>19</tool_uses><duration_ms>268102</duration_ms></usage> </task-notification>

diff --git a/infra/modules/region-host/main.tf b/infra/modules/region-host/main.tf
index abf3fb8c5..23c9ea29b 100644
--- a/infra/modules/region-host/main.tf
+++ b/infra/modules/region-host/main.tf
@@ -446,15 +446,17 @@ resource "aws_iam_role_policy" "host_costexplorer" {
})
}
-# Analytics version prune (the console's daily 400-day statistics prune,
+# Analytics version prune (the console's daily statistics prune,
# internal/analytics): the deployment bucket is versioned and every day file
# is rewritten on each usage flush, so deleting an expired day file for good
# means deleting each of its versions and delete markers. Off by default:
# only the box that runs the console needs it. Version listing is held to
-# the apps/ prefix and version deletion to exactly the analytics day files,
-# apps/<acct>/<app>/analytics/<box>/days/<file>; nothing else in the
-# deployment bucket loses a version through this grant, and the data bucket
-# grants above are untouched. The deployment bucket's own box-evidence Deny
+# the apps/ prefix. The version-delete resource pattern
+# apps/*/*/analytics/*/days/* is not an exact day-file boundary: IAM's `*`
+# also matches `/`, so it can match keys with `/analytics/` followed by
+# `/days/` at arbitrary depth. The prune code re-checks the expected prefix
+# and exact date-file leaf immediately before deleting each version. The data
+# bucket grants above are untouched. The deployment bucket's own box-evidence Deny
# (deployment-buckets/main.tf, BoxRecordsAreNeverDeleted) covers control/
# only and still wins over any Allow.
resource "aws_iam_role_policy" "host_analytics_prune" {
diff --git a/infra/modules/region-host/variables.tf b/infra/modules/region-host/variables.tf
index 48e25e122..77dff8649 100644
--- a/infra/modules/region-host/variables.tf
+++ b/infra/modules/region-host/variables.tf
@@ -207,7 +207,7 @@ variable "enable_cost_explorer" {
}
variable "enable_analytics_version_prune" {
- description = "Let this host's role list object versions under apps/ in the deployment bucket and delete versions of analytics day files only (apps/*/*/analytics/*/days/*), so the console's statistics prune removes every version of an expired day file. Off by default. Set it only on the box that runs the console, in fixed mode."
+ description = "Let this host's role list object versions under apps/ in the deployment bucket and delete versions matching apps/*/*/analytics/*/days/*. In IAM, * also matches /, so this pattern can match keys with /analytics/ then /days/ at arbitrary depth; the prune code enforces the expected prefix and exact date-file leaf before deleting. Off by default. Set it only on the box that runs the console, in fixed mode."
type = bool
default = false
}
diff --git a/internal/console/analyticsprune.go b/internal/console/analyticsprune.go
index 1629b33f8..19a2bb606 100644
--- a/internal/console/analyticsprune.go
+++ b/internal/console/analyticsprune.go
@@ -12,7 +12,15 @@ import (
"github.com/carlosframework/platform/internal/analytics"
)
-const analyticsPruneTimeout = 10 * time.Minute
+const (
+ analyticsPruneTimeout = 10 * time.Minute
+ // A busy app-box-day has 24*60/5 = 288 versions. Two million covers
+ // about 6,944 such days, or 2,000 full DeleteObjects batches of 1,000.
+ // Allow ten listed entries per deletion for retained or malformed keys;
+ // these are safety bounds, with the ten-minute deadline limiting work.
+ analyticsPruneMaxDeletes = 2_000_000
+ analyticsPruneMaxKeys = 10 * analyticsPruneMaxDeletes
+)
func parseAnalyticsRetention(daysRaw, dryRunRaw string) (days int, dryRun bool, err error) {
if daysRaw != "" {
@@ -37,6 +45,10 @@ func parseAnalyticsRetention(daysRaw, dryRunRaw string) (days int, dryRun bool,
// attempt before I/O deliberately defers a failed or interrupted pass until
// tomorrow instead of issuing another bucket sweep on each boot.
func (s *Server) analyticsPrunePass(ctx context.Context, now time.Time) error {
+ return s.analyticsPrunePassWithLimits(ctx, now, analyticsPruneMaxDeletes, analyticsPruneMaxKeys)
+}
+
+func (s *Server) analyticsPrunePassWithLimits(ctx context.Context, now time.Time, maxDeletes, maxKeys int) error {
days, dryRun, err := parseAnalyticsRetention(s.cfg.AnalyticsRetentionDays, s.cfg.AnalyticsRetentionDryRun)
if err != nil {
return err
@@ -65,10 +77,17 @@ func (s *Server) analyticsPrunePass(ctx context.Context, now time.Time) error {
s.pruneAnalyticsCaches(now)
}
stats, pruneErr := analytics.Prune(ctx, s.cfg.Releases, now, analytics.PruneOptions{
- RetentionDays: days, DryRun: dryRun, PageSize: 1000, MaxDeletes: 10000, MaxKeys: 100000, StartAt: cursor,
+ RetentionDays: days, DryRun: dryRun, PageSize: 1000, MaxDeletes: maxDeletes, MaxKeys: maxKeys, StartAt: cursor,
})
- log.Printf("console: analytics prune: retention_days=%d dry_run=%t apps=%d boxes=%d entries_listed=%d deleted=%d would_delete=%d keys_listed=%d versions_listed=%d keys_deleted=%d versions_deleted=%d keys_would_delete=%d versions_would_delete=%d skipped_malformed=%d errors=%d list_requests=%d delete_requests=%d next_box=%q",
- days, dryRun, stats.Apps, stats.Boxes, stats.Listed, stats.Deleted, stats.WouldDelete, stats.KeysListed, stats.VersionsListed, stats.KeysDeleted, stats.VersionsDeleted, stats.KeysWouldDelete, stats.VersionsWouldDelete, stats.Malformed, stats.Errors, stats.ListCalls, stats.DeleteCalls, stats.NextBox)
+ warning := ""
+ if stats.NextBox != "" || ctx.Err() != nil || errors.Is(pruneErr, context.DeadlineExceeded) {
+ warning = "warning: backlog remains: "
+ // Returning this error also fails the economics job through its
+ // existing jobFailed call, even when the store itself succeeded.
+ pruneErr = errors.Join(pruneErr, fmt.Errorf("analytics prune: backlog remains: entries_listed=%d deleted=%d would_delete=%d next_box=%q", stats.Listed, stats.Deleted, stats.WouldDelete, stats.NextBox))
+ }
+ log.Printf("console: analytics prune: %sretention_days=%d dry_run=%t apps=%d boxes=%d entries_listed=%d deleted=%d would_delete=%d keys_listed=%d versions_listed=%d keys_deleted=%d versions_deleted=%d keys_would_delete=%d versions_would_delete=%d skipped_malformed=%d errors=%d list_requests=%d delete_requests=%d next_box=%q",
+ warning, days, dryRun, stats.Apps, stats.Boxes, stats.Listed, stats.Deleted, stats.WouldDelete, stats.KeysListed, stats.VersionsListed, stats.KeysDeleted, stats.VersionsDeleted, stats.KeysWouldDelete, stats.VersionsWouldDelete, stats.Malformed, stats.Errors, stats.ListCalls, stats.DeleteCalls, stats.NextBox)
// A timeout must not prevent saving progress. This final local write has
// its own small deadline, independent of the bucket work's deadline.
saveCtx, saveCancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second)
diff --git a/internal/console/analyticsprune_versions_test.go b/internal/console/analyticsprune_versions_test.go
new file mode 100644
index 000000000..71a8162d6
--- /dev/null
+++ b/internal/console/analyticsprune_versions_test.go
@@ -0,0 +1,210 @@
+package console
+
+import (
+ "bytes"
+ "context"
+ "errors"
+ "fmt"
+ "log"
+ "slices"
+ "strings"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/analytics"
+ "github.com/carlosframework/platform/internal/release"
+)
+
+// Keep the original order so continuation markers still work after deletion.
+// The nil Store makes any fallback to current-key operations fail the test.
+type analyticsPruneVersionStore struct {
+ release.Store
+ versions []release.ObjectVersion
+ removed map[release.ObjectVersion]bool
+ pages []string
+ wait bool
+}
+
+func newAnalyticsPruneVersionStore(t *testing.T, apps, boxes, versions int) *analyticsPruneVersionStore {
+ t.Helper()
+ st := &analyticsPruneVersionStore{removed: make(map[release.ObjectVersion]bool)}
+ for app := 0; app < apps; app++ {
+ for box := 0; box < boxes; box++ {
+ key, err := analytics.DayKey("bab", fmt.Sprintf("app-%02d", app), fmt.Sprintf("box-%02d", box), "2020-01-01")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for v := 0; v < versions; v++ {
+ st.versions = append(st.versions, release.ObjectVersion{Key: key, VersionID: fmt.Sprintf("v%d", v), IsDeleteMarker: v == 0})
+ }
+ }
+ }
+ return st
+}
+
+func (s *analyticsPruneVersionStore) ListVersionDirsWithCount(ctx context.Context, prefix string) ([]string, int, error) {
+ seen := map[string]bool{}
+ for _, v := range s.versions {
+ if s.removed[v] {
+ continue
+ }
+ if rest, ok := strings.CutPrefix(v.Key, prefix); ok {
+ if child, _, ok := strings.Cut(rest, "/"); ok {
+ seen[prefix+child+"/"] = true
+ }
+ }
+ }
+ var dirs []string
+ for dir := range seen {
+ dirs = append(dirs, dir)
+ }
+ slices.Sort(dirs)
+ return dirs, 1, ctx.Err()
+}
+
+func (s *analyticsPruneVersionStore) ListVersionsPage(ctx context.Context, prefix, keyMarker, versionMarker string, limit int) ([]release.ObjectVersion, string, string, error) {
+ s.pages = append(s.pages, prefix)
+ if s.wait {
+ <-ctx.Done()
+ return nil, "", "", ctx.Err()
+ }
+ start := 0
+ if keyMarker != "" || versionMarker != "" {
+ found := false
+ for i, v := range s.versions {
+ if v.Key == keyMarker && v.VersionID == versionMarker {
+ start, found = i+1, true
+ break
+ }
+ }
+ if !found {
+ return nil, "", "", fmt.Errorf("unknown version continuation %q %q", keyMarker, versionMarker)
+ }
+ }
+ var page []release.ObjectVersion
+ for _, v := range s.versions[start:] {
+ if !strings.HasPrefix(v.Key, prefix) || s.removed[v] {
+ continue
+ }
+ if len(page) == limit {
+ last := page[len(page)-1]
+ return page, last.Key, last.VersionID, nil
+ }
+ page = append(page, v)
+ }
+ return page, "", "", ctx.Err()
+}
+
+func (s *analyticsPruneVersionStore) DeleteVersions(ctx context.Context, versions []release.ObjectVersion) error {
+ if len(versions) > 1000 {
+ return fmt.Errorf("oversized delete batch: %d", len(versions))
+ }
+ for _, v := range versions {
+ if s.removed[v] {
+ return fmt.Errorf("version deleted twice: %+v", v)
+ }
+ s.removed[v] = true
+ }
+ return ctx.Err()
+}
+
+func TestAnalyticsPruneDefaultCapsClearBusyFleet(t *testing.T) {
+ const apps, boxes, versions = 4, 12, 288
+ st := newAnalyticsPruneVersionStore(t, apps, boxes, versions)
+ srv := &Server{store: openTestStore(t), cfg: Config{Releases: st, AnalyticsRetentionDays: "400"}}
+ if err := srv.analyticsPrunePass(t.Context(), time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ if len(st.removed) != apps*boxes*versions {
+ t.Fatalf("deleted %d versions, want %d", len(st.removed), apps*boxes*versions)
+ }
+ var cursor string
+ if err := srv.store.db.QueryRow(`SELECT next_box FROM analytics_prune_state WHERE id = 1`).Scan(&cursor); err != nil {
+ t.Fatal(err)
+ }
+ if cursor != "" {
+ t.Fatalf("completed pass saved cursor %q", cursor)
+ }
+}
+
+func TestAnalyticsPruneBacklogFailsJobAndResumes(t *testing.T) {
+ for _, stop := range []string{"deletes", "listed", "deadline"} {
+ t.Run(stop, func(t *testing.T) {
+ st := newAnalyticsPruneVersionStore(t, 1, 2, 288)
+ srv := &Server{store: openTestStore(t), cfg: Config{Releases: st, AnalyticsRetentionDays: "400"}}
+ now := time.Now()
+ jobs := newJobRegistry(func() time.Time { return now })
+ var logs bytes.Buffer
+ oldWriter := log.Writer()
+ log.SetOutput(&logs)
+ t.Cleanup(func() { log.SetOutput(oldWriter) })
+ maxDeletes, maxKeys, wantDeleted := analyticsPruneMaxDeletes, analyticsPruneMaxKeys, 300
+ ctx := t.Context()
+ switch stop {
+ case "deletes":
+ maxDeletes = 300
+ case "listed":
+ maxKeys = 300
+ case "deadline":
+ st.wait, wantDeleted = true, 0
+ var cancel context.CancelFunc
+ ctx, cancel = context.WithTimeout(ctx, 250*time.Millisecond)
+ defer cancel()
+ }
+ // Economics records a prune error with jobFailed and continues
+ // its other stages. Exercise that same job-registry path here.
+ var pruneErr error
+ if err := jobs.Run(ctx, "economics", func(ctx context.Context) error {
+ pruneErr = srv.analyticsPrunePassWithLimits(ctx, now, maxDeletes, maxKeys)
+ jobFailed(ctx, pruneErr)
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if pruneErr == nil || !strings.Contains(pruneErr.Error(), "backlog remains") {
+ t.Fatalf("unfinished pass error: %v", pruneErr)
+ }
+ if stop == "deadline" && !errors.Is(pruneErr, context.DeadlineExceeded) {
+ t.Fatalf("deadline error lost: %v", pruneErr)
+ }
+ status := jobs.Snapshot()[0]
+ if status.State != JobFailed || !strings.Contains(status.Err, "backlog remains") {
+ t.Fatalf("unfinished pass job status: %+v", status)
+ }
+ if len(st.removed) != wantDeleted {
+ t.Fatalf("deleted %d versions, want %d", len(st.removed), wantDeleted)
+ }
+ for _, field := range []string{"warning: backlog remains:", "apps=1", "boxes=", "entries_listed=", fmt.Sprintf("deleted=%d", wantDeleted), "versions_deleted=", "list_requests=", "delete_requests=", "next_box="} {
+ if !strings.Contains(logs.String(), field) {
+ t.Errorf("backlog log missing %q: %s", field, &logs)
+ }
+ }
+ var cursor string
+ if err := srv.store.db.QueryRow(`SELECT next_box FROM analytics_prune_state WHERE id = 1`).Scan(&cursor); err != nil || cursor == "" {
+ t.Fatalf("saved cursor=%q err=%v", cursor, err)
+ }
+ pageCount := len(st.pages)
+ if err := srv.analyticsPrunePass(t.Context(), now.Add(23*time.Hour)); err != nil || len(st.pages) != pageCount {
+ t.Fatalf("early retry: pages=%d, want %d, err=%v", len(st.pages), pageCount, err)
+ }
+ st.wait = false
+ logs.Reset()
+ now = now.Add(24 * time.Hour)
+ // The next day's pass uses the same caps and the persisted cursor.
+ if err := jobs.Run(t.Context(), "economics", func(ctx context.Context) error {
+ return srv.analyticsPrunePassWithLimits(ctx, now, maxDeletes, maxKeys)
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if len(st.removed) != len(st.versions) || st.pages[pageCount] != cursor {
+ t.Fatalf("resume: removed=%d/%d first prefix=%q want=%q", len(st.removed), len(st.versions), st.pages[pageCount], cursor)
+ }
+ if err := srv.store.db.QueryRow(`SELECT next_box FROM analytics_prune_state WHERE id = 1`).Scan(&cursor); err != nil || cursor != "" {
+ t.Fatalf("finished cursor=%q err=%v", cursor, err)
+ }
+ if status := jobs.Snapshot()[0]; status.State != JobOK || strings.Contains(logs.String(), "warning:") {
+ t.Fatalf("completed pass: status=%+v logs=%s", status, &logs)
+ }
+ })
+ }
+}