Skip to content

keep_n_duplicated_package_files cleanup policy is not adapted to Conan

Background

The keep_n_duplicated_package_files cleanup policy is currently implemented in Packages::Cleanup::ExecutePolicyService with a one-size-fits-all approach that doesn't account for Conan's unique package reference system. The only Conan-specific handling is a special case for manifest files.

Technical Details

Current implementation issues:

  1. The cleanup service groups package files by package_id and file_name only:
package_files.group(:package_id, :file_name)
  .having("COUNT(*) > #{@policy.keep_n_duplicated_package_files}")
  1. This ignores Conan's package reference system which is designed to handle different build configurations:

    • Each Conan package can have multiple package references (Packages::Conan::PackageReference)
    • Package references represent different build settings/options, not versions
  2. The current implementation may delete valid package files when:

    • A package has multiple references (different build configs)
    • Soon, when a package has multiple revisions as well (conan v2)

Impact

  1. Data Loss Risk:

    • Users may lose package files for specific build configurations or architectures
    • CI/CD pipelines depending on specific package configurations may break
  2. User Experience:

    • Unexpected behavior for Conan users
    • Potential loss of important package variants

Proposed Solution

  • For v1, keep n duplicate file by package_reference for package files, also separate by file type: recipe vs package to have a cleaner way of managing manifest files.
  • For v2, or v1 with revision, have new options:
    • Number of recipe revisions to keep
    • Number of package revisions to keep per reference
Edited by 🤖 GitLab Bot 🤖