Skip to content

feat: add account_advisory cleanup to advisory cleanup job - #2290

Draft
katarinazaprazna wants to merge 2 commits into
RedHatInsights:masterfrom
katarinazaprazna:parallel-advisory-cleanup
Draft

feat: add account_advisory cleanup to advisory cleanup job#2290
katarinazaprazna wants to merge 2 commits into
RedHatInsights:masterfrom
katarinazaprazna:parallel-advisory-cleanup

Conversation

@katarinazaprazna

@katarinazaprazna katarinazaprazna commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Extend the advisory cleanup job to also clean zero-count rows from the new account_advisory table, running both cleanups in parallel until the legacy table is dropped
  • Prevent deleting advisory_metadata that still has rows in the new table
  • Add row-count logging to cleanups for observability

Follow-up

  • PUT /clean-advisory-account-data admin API endpoint only cleans the legacy table. Update to also clean account_advisory (or rename/replace when legacy table is dropped)

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Extend the advisory cleanup job to also clean zero-count rows from the
new account_advisory table, running both cleanups in parallel. The
legacy advisory_account_data cleanup runs until that table is dropped.
@sourcery-ai

sourcery-ai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Extend the advisory cleanup job to run zero-count row deletion on both advisory_account_data and account_advisory tables in parallel, rename the job wiring, and add per-table deletion count logging for observability.

File-Level Changes

Change Details Files
Introduce a new parallel cleanup task that deletes zero-count advisory rows from both legacy and new tables with row-count logging.
  • Add RunCleanAccountAdvisory task that configures the app, runs two cleanup goroutines in parallel, and waits for completion
  • Implement CleanAdvisoryAccountData to delete rows with non-positive system counts from the legacy advisory_account_data table using a cancelable transaction
  • Implement CleanAccountAdvisory to delete rows with non-positive system counts from the new account_advisory table using a cancelable transaction
  • Add informational and error logging around both cleanups, including number of deleted rows
tasks/cleaning/clean_account_advisory.go
Rename and rewire the advisory cleanup cron job to use the new combined account advisory cleanup task and environment parameters.
  • Rename the advisory cleanup job spec and command to clean_account_advisory
  • Switch cron schedule and suspend parameters from CLEAN_AAD_* to CLEAN_AA_*
  • Remove the old clean_advisory_account_data job entrypoint mapping
deploy/clowdapp.yaml
main.go
tasks/cleaning/clean_advisory_account_data.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.56410% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.16%. Comparing base (7ae4e4b) to head (5c64f33).

Files with missing lines Patch % Lines
tasks/cleaning/clean_account_advisory.go 0.00% 36 Missing ⚠️
main.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2290      +/-   ##
==========================================
- Coverage   59.27%   59.16%   -0.12%     
==========================================
  Files         148      148              
  Lines        9488     9508      +20     
==========================================
+ Hits         5624     5625       +1     
- Misses       3276     3295      +19     
  Partials      588      588              
Flag Coverage Δ
unittests 59.16% <2.56%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@katarinazaprazna
katarinazaprazna force-pushed the parallel-advisory-cleanup branch from d447030 to 5c64f33 Compare August 3, 2026 00:30
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.

2 participants