Add virtual registries cleanup policies model and DB table
What does this MR do and why?
This MR adds the database table, model for virtual registries clean-up policies. It includes:
- A new
virtual_registries_cleanup_policies
database table to store clean-up policy configurations for virtual registries - A corresponding
VirtualRegistries::Cleanup::Policy
model with validations and associations - JSON schema validation for detailed clean-up metrics
- Factory definitions and specs for testing
This implementation is necessary to support automated clean-up of unused artifacts in virtual registries, helping organizations manage storage more efficiently and reduce costs. The clean-up policies will allow administrators to configure retention rules based on time since last download, with configurable cadence for clean-up jobs.
References
Screenshots or screen recordings
N/A
How to set up and validate locally
-
Run database migrations to create the new table:
bundle exec rake db:migrate
-
Create a test clean-up policy via rails console:
group = Group.top_level.first policy = VirtualRegistries::Cleanup::Policy.create!( group: group, enabled: true, keep_n_days_after_download: 30, cadence: 7, notify_on_success: true )
-
Test validation rules by attempting invalid configurations:
invalid_policy = VirtualRegistries::Cleanup::Policy.new( group: group, keep_n_days_after_download: -1 # Should fail validation ) invalid_policy.valid? # Should return false invalid_policy.errors.full_messages # Should show validation errors
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #567200 (closed)