-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce maintenance tasks; Unify cron and lock duration configs for tasks #840
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
18689e4
to
70d4d71
Compare
513f55c
to
e03fcff
Compare
283094a
to
989ecee
Compare
5319d08
to
6c5e730
Compare
faecfa9
to
2deddf4
Compare
ef0de73
to
8ab260e
Compare
235fd7a
to
9fac32d
Compare
9fac32d
to
5c8f3ab
Compare
… tasks Adds maintenance tasks to help with freeing the database from unwanted bloat: * `ComponentMetadataMaintenanceTask` deletes dangling `IntegrityMetaComponent` and `RepositoryMetaComponent` records, which would otherwise accumulate forever. * `MetricsMaintenanceTask` deletes metrics records older than a configurable retention period (90 days per default). Since the frontend only shows metrics for up to 90 days, it doesn't make sense to keep older data around. Users with longer retention requirements can re-configure this in the UI. * `TagMaintenanceTask` deletes tags that are not used, i.e. not associated with any project, policy, or notification rule. This is particularly useful for organizations that make use of ephemeral, or frequently changing tags. * `VulnerabilityDatabaseMaintenanceTask` deletes `VulnerableSoftware` records that are no longer referenced by any `Vulnerability`. Such orphaned records can happen when vulnerability databases such as the NVD update a vulnerability's affected version ranges, or affected components entirely. The following existing cleanup tasks were renamed accordingly to fit the new maintenance convention: * `VulnerabilityScanCleanupTask` -> `VulnerabilityScanMaintenanceTask` * `WorkflowStateCleanupTask` -> `WorkflowMaintenanceTask` They were additionally refactored to make use of bulk SQL `UPDATE` / `DELETE` statements, rather than modifying individual records via the ORM. This makes them both better performing and more concurrency-friendly. The way how cron and lock duration configuration is retrieved for tasks was refactored to be more uniform. Now, property names align with a task's class name, and follow a predictable structure, voiding the need for separate `ConfigKey` definitions. For example: * `task.cron.metrics.portfolio` -> `task.portfolio.metrics.update.cron` * `task.metrics.portfolio.lockAtMostForInMillis` -> `task.portfolio.metrics.update.lock.max.duration` * `task.metrics.portfolio.lockAtLeastForInMillis` -> `task.portfolio.metrics.update.lock.min.duration` Signed-off-by: nscuro <[email protected]>
5c8f3ab
to
9bfe302
Compare
Description
Adds maintenance tasks to help with freeing the database from unwanted bloat:
ComponentMetadataMaintenanceTask
deletes danglingIntegrityMetaComponent
andRepositoryMetaComponent
records, which would otherwise accumulate forever.MetricsMaintenanceTask
deletes metrics records older than a configurable retention period (90 days per default). Since the frontend only shows metrics for up to 90 days, it doesn't make sense to keep older data around. Users with longer retention requirements can re-configure this in the UI.TagMaintenanceTask
deletes tags that are not used, i.e. not associated with any project, policy, or notification rule. This is particularly useful for organizations that make use of ephemeral, or frequently changing tags.VulnerabilityDatabaseMaintenanceTask
deletesVulnerableSoftware
records that are no longer referenced by anyVulnerability
. Such orphaned records can happen when vulnerability databases such as the NVD update a vulnerability's affected version ranges, or affected components entirely.The following existing cleanup tasks were renamed accordingly to fit the new maintenance convention:
VulnerabilityScanCleanupTask
->VulnerabilityScanMaintenanceTask
WorkflowStateCleanupTask
->WorkflowMaintenanceTask
They were additionally refactored to make use of bulk SQL
UPDATE
/DELETE
statements, rather than modifying individual records via the ORM. This makes them both better performing and more concurrency-friendly.The way how cron and lock duration configuration is retrieved for tasks was refactored to be more uniform. Now, property names align with a task's class name, and follow a predictable structure, voiding the need for separate
ConfigKey
definitions.For example:
task.cron.metrics.portfolio
->task.portfolio.metrics.update.cron
task.metrics.portfolio.lockAtMostForInMillis
->task.portfolio.metrics.update.lock.max.duration
task.metrics.portfolio.lockAtLeastForInMillis
->task.portfolio.metrics.update.lock.min.duration
Addressed Issue
N/A
Additional Details
N/A
Checklist
This PR fixes a defect, and I have provided tests to verify that the fix is effectiveThis PR introduces changes to the database model, and I have updated the migration changelog accordinglyThis PR introduces new or alters existing behavior, and I have updated the documentation accordingly