[AAP-101700] XLAB Unify hourly sync and backfill job definition and update existing data #543
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #543"
general
weight: 0.35
kcagran
[AAP-101700] Unify hourly sync and backfill job definition and update existing data
Description
<!-- Mandatory: Provide a clear, concise description of the changes and their purpose -->
- added a new column
launch_typetojobdatamodel - a new migration is added- to be able to unify hourly sync and backfill job definition
- see above
Type of Change
<!-- Mandatory: Check one or more boxes that apply -->
Self-Review Checklist
<!-- These items help ensure quality - they complement our automated CI checks -->
Testing Instructions
<!-- Optional for test-only changes. Mandatory for all other changes -->
<!-- Must be detailed enough for reviewers to reproduce -->
Prerequisites
metrics-utility>=0.8.20261118(released; includes ansible/metrics-utility#640).uv syncinstalls it.envsourced, compose stack up (make compose), then migrate and register tasks:tools/dev.sh --init, admin/admin).psql -h <host> -U <user> -d <awx_db>):1. Stand-in template/project row.
tools/seed-awx-demo.sqlassumes template and project id 1 exist, and on an empty AWX DB they don't:<details><summary>SQL</summary>
</details>
2. Run the contents of
tools/seed-awx-demo.sql(12manual/scheduledjobs; safe to repeat). Withpsql:-f tools/seed-awx-demo.sql.3. The seed has no
sync/workflowjobs, so set one of each:Result: 12 jobs (6 manual, 4 scheduled, 1 sync, 1 workflow). The seed jobs have no
polymorphic_ctype, so the collector logsreturned N rows without a usable model. This is harmless.The snippets below run in
manage.py shellwith:Steps to Test
1. Migration:
python manage.py makemigrations --check --dry-runreports no changes, anddashboard_reports.0005_jobdata_launch_typeis applied (showmigrations dashboard_reports).2. Update task, existing install (initial collection
completed):- The result has no
skippedkey and showsprocessed/updated/added/failed.- The second run adds nothing and
JobData.objects.count()doesn't grow (idempotent).- To simulate pre-migration rows, run
JobData.objects.update(launch_type=None)and run the task again. Expectupdated: 12, added: 0and no NULLlaunch_typeleft.3. Update task, any initial collection status: for each of
pending,running,failed,cancelled, set the status ofinitial_dashboard_collection, runJobData.objects.update(launch_type=None), then runupdate_dashboard_job_definition. It always runs (noskippedkey): the NULL rows getlaunch_typefilled and missing jobs are added. Set the status back tocompletedafterwards.4. Backfill (cursor pagination): the batch size is the setting
DASHBOARD_COLLECTION.BACKFILL_BATCH_SIZE, not a task parameter (default 5000).In
manage.py shell, runJobData.objects.all().delete(), thenTASK_FUNCTIONS['collect_dashboard_reports_initial_data']().- The logs show
Synced batch of 5 jobs (total so far: 5), then... 10, thenSynced batch of 2 jobs (total so far: 12).-
JobDatahas all 12 jobs, with no gaps or repeats, and all four launch types.5. Hourly hook: with the dispatcher running, delete the old chunks and rows, then run the hook for each UTC hour that contains jobs (the seed uses the previous four full hours):
The hook queues
sync_dashboard_job_recordstasks, which the dispatcher runs. Wait until they'recompleted. A task that hitCould not acquire lock 'sync_dashboard_job_records'retries after about 8 minutes (existing lock behavior). Then check thatJobDataholds all 12 jobs, includingsyncandworkflow, withlaunch_typeset.6. Read-time filtering:
-
runsis 10 (6 successful, 4 failed) out of 12 stored jobs.JobData.objects.exclude(launch_type__in=['sync','workflow']).count()is 10.- The details, export and leaderboard endpoints use the same filter.
syncandworkflowjobs must not appear, and results for existing jobs are unchanged.7. Subscription cost (instance method):
Rows with NULL
launch_type(legacy) still count.Expected Results
apps/dashboard_reports/job_definition.py).launch_typeand missing jobs without duplicating rows, and a second run changes nothing.syncandworkflowjobs.syncandworkflowjobs are hidden at read time.per_second_subscription_costexcludessync/workflowrows. Legacy NULL rows still count.