Skip to content

feat/prune age#1970

Open
alanpeixinho wants to merge 3 commits into
kernelci:mainfrom
profusion:feat/prune-age
Open

feat/prune age#1970
alanpeixinho wants to merge 3 commits into
kernelci:mainfrom
profusion:feat/prune-age

Conversation

@alanpeixinho

@alanpeixinho alanpeixinho commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Add prune_db, a manual management command to delete old data and reclaim space.

  • Deletes checkouts, builds and tests older than a given age (e.g. --older-than "30 days").
  • Manual cascade (models use DO_NOTHING): pruning a checkout removes its builds, pruning a build removes its tests — even when children are newer.
  • --origins scopes the age filter; cascade stays origin-agnostic so no orphans are left.
  • Batched deletes (--batch-size) that each commit on their own to keep locks short.
  • --dry-run and a per-table confirmation prompt showing exactly how many rows will be affected (skip with --yes).
  • Extracts parse_interval from update_db into a shared helper.

Usage

python manage.py prune_db --older-than "30 days" --dry-run                                                                                                                                                         
python manage.py prune_db --older-than "30 days" --origins maestro                                                                                                                                          

How to Test

  • In a local database create newly seeded data poetry run python3 manage.py seed_data --clear --yes
  • Run command poetry run python3 manage.py prune_db --dry-run with different arguments for older-than parameter.
  • Verify the number of selected rows matches the database.
  • Run command poetry run python3 manage.py prune_db with different arguments for older-than parameter.
  • Verify the rows are properly deleted.

  * Delete rows older than a given age with manual cascade (checkout -> builds -> tests)
  * --origins scoping, --dry-run and a --yes confirmation.
  Extract parse_interval into a shared helper and add integration tests.

  Closes kernelci#1969

Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
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.

1 participant