Skip to content

feat(hardware): add daily hardware aggregates recomputed from raw - #2037

Closed
alanpeixinho wants to merge 3 commits into
mainfrom
feat/hardware-daily-aggregates
Closed

alanpeixinho wants to merge 3 commits into
mainfrom
feat/hardware-daily-aggregates

Conversation

@alanpeixinho

@alanpeixinho alanpeixinho commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2178. Merge that first. It adds the tables.

What it is

Adds daily hardware aggregate tables (hardware_daily_builds, hardware_daily_tests) built from raw checkouts / builds / tests.

  • recompute_hardware_daily: idempotent per-day rebuild (DELETE + INSERT). Uses temp tables so the raw join runs once per day. Advisory locks avoid concurrent collisions. If raw is pruned but aggregates
    exist, keeps the stale rows.
  • Cron: hourly --days=1 (today), every 6h --days=7 — no 60-day batch.
  • prune_db: can prune aggregates by checkout_day independently of raw.
  • update_db / seed_test_data: snapshot/restore and seed support for the new tables.
  • hardware_status: unchanged — still written and read as before.

Closes #2034.

How to test

migrate

Run local database and apply migration

manual recompute

python manage.py recompute_hardware_daily --day=2025-07-18
python manage.py recompute_hardware_daily --days=7

verify rows

Check that the aggregate counts for builds, boots and tests match the sum of the raw tables (builds and tests).

prune dry-run (aggregates only)

python manage.py prune_db --older-than "30 days" \ --tables hardware_daily_builds,hardware_daily_tests --dry-run

@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch 3 times, most recently from 39d0d5b to 27eb2e6 Compare August 17, 2026 21:59
@alanpeixinho alanpeixinho changed the title feat(hardware): add daily hardware aggregates recomputed from raw [WIP] feat(hardware): add daily hardware aggregates recomputed from raw Aug 17, 2026
@alanpeixinho
alanpeixinho marked this pull request as ready for review August 17, 2026 22:10
@alanpeixinho
alanpeixinho marked this pull request as draft August 17, 2026 22:13
@alanpeixinho
alanpeixinho marked this pull request as ready for review August 25, 2026 12:59
@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch from b5c7772 to 89f9401 Compare August 25, 2026 14:36

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--origins does not apply to hardware_daily_* ?

Those tables are in the default --tables set and are deleted with only checkout_day < cutoff. running prune_db --older-than "30 days" --origins maestro (the docs example) can wipe every origin’s daily aggregates while leaving other tenants’ raw rows.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Daily prune was ignoring --origins and deleting by checkout_day only. Fixed in c9392fb — hardware_daily_* now filter on checkout_origin the same way raw rows use origin.

@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch 2 times, most recently from ea02b2d to c9392fb Compare September 2, 2026 17:29
@alanpeixinho alanpeixinho changed the title [WIP] feat(hardware): add daily hardware aggregates recomputed from raw feat(hardware): add daily hardware aggregates recomputed from raw Sep 4, 2026
@alanpeixinho
alanpeixinho force-pushed the feat/hardware-daily-aggregates branch from ac58f3a to 43c8bc7 Compare September 23, 2026 12:57
@alanpeixinho

Copy link
Copy Markdown
Contributor Author

@nuclearcat this PR creates new tables to deal with hardware aggregation for the changes required by #2034.

@nuclearcat

Copy link
Copy Markdown
Member

@nuclearcat this PR creates new tables to deal with hardware aggregation for the changes required by #2034.

ping me in discord when you want to deploy it

Add hardware_daily_builds and hardware_daily_tests keyed by checkout
day, origin, lab, and platform. Depends on the labs migration already
on main, so no merge migration is required.

Signed-off-by: Alan Peixinho <[email protected]>
Rebuild one UTC day at a time with DELETE + INSERT, an advisory lock,
and a rollback when raw rows are gone. Materialize the day's tests
once, ANALYZE them, and raise work_mem so the planner hashes instead
of spilling. Cron refreshes today hourly and the last 15 days every
6 hours. Wire prune_db, seed_test_data, and update_db for the new
tables.

Closes #2034

Signed-off-by: Alan Peixinho <[email protected]>
Filter hardware_daily_* on checkout_origin the same way raw rows use
origin, so an origin-scoped prune cannot wipe every tenant's aggregates.

Signed-off-by: Alan Peixinho <[email protected]>
@alanpeixinho

Copy link
Copy Markdown
Contributor Author

Depends on #2178. Merge that first. It adds the tables.

@alanpeixinho

Copy link
Copy Markdown
Contributor Author

Moved to #2181 so the PR is opened from profusion, not from kernelci. The recompute commits are the same. Closing this.

@alanpeixinho
alanpeixinho deleted the feat/hardware-daily-aggregates branch October 15, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HW-list: split hardware_status (migration + aggregations)

3 participants