Skip to content

Conversation

quba42
Copy link
Contributor

@quba42 quba42 commented Sep 2, 2025

What are the changes introduced in this pull request?

Right now, "structured APT" for deb type content is an optional feature that can be enabled or disabled using a setting.

With this PR all users upgrading to a Katello version with these changes will be migrated to use structured APT. The code is cleaned up to reflect the assumption that all deb type content will use structured APT hence forth.

Considerations taken when implementing this change?

Everything is based on the assumption that lib/katello/tasks/upgrades/4.19/enable_structured_apt_for_deb.rake will be run during upgrade to Katello 4.19. This is essential because the new code assumes there is no deb content left that was not migrated by the rake task. Is this a safe assumption?

What are the testing steps for this pull request?

  1. Create some deb type content on your instance without these changes (make sure structured APT is disabled for this).
  2. Apply these changes.
  3. Run the rake task (should happen automatically when using a proper upgrade path).
  4. Re-sync any deb content to any smart proxies.
  5. Check that all deb content still works and is using structured APT mode.

Summary by Sourcery

Make structured APT mandatory for all deb repositories by removing the feature toggle, cleaning up related code paths, consolidating Pulp API interactions, and providing a migration task to convert existing repos to the new mode.

New Features:

  • Add a Rake upgrade task to migrate existing Debian repos to structured APT mode.

Enhancements:

  • Remove the optional structured APT feature flag and assume all deb content uses structured APT.
  • Consolidate Pulp API access with new pulp_primary_api, pulp_components, and pulp_distributions methods.
  • Simplify and clean up legacy logic by removing conditional checks and helper methods for non-structured APT workflows.
  • Remove the deb_enable_structured_apt plugin setting and related configuration toggles.

Tests:

  • Update test expectations to reflect the always-on structured APT behavior.

Copy link

sourcery-ai bot commented Sep 2, 2025

Reviewer's Guide

This PR removes the optional structured APT setting, making all deb content use structured APT by default. It centralizes Pulp API interactions in the Apt service, refactors repository URL handling, updates action and controller code to treat deb repos uniformly, and delivers a one-off rake task to migrate existing repos during upgrade.

File-Level Changes

Change Details Files
Centralize Pulp API calls and structured APT logic in the Apt service
  • Introduce pulp_primary_api to always target the main Pulp server
  • Implement pulp_components and pulp_distributions with content_release_components_api
  • Add sanitize_pulp_distribution helper
  • Simplify mirror_remote_options to use pulp_distributions
  • Refactor version_missing_structure_content? and publication_options to use the centralized API
app/services/katello/pulp3/repository/apt.rb
Eliminate optional structured APT toggles and settings
  • Remove deb_using_structured_apt? delegate and root_repository method
  • Drop 'deb_enable_structured_apt' plugin setting
  • Clean up legacy structured/simple branching in models
app/models/katello/root_repository.rb
lib/katello/plugin.rb
Refactor repository content URL and metadata handling
  • Update deb_content_url_options to use backend_service.pulp_components/distributions
  • Remove legacy deb_pulp_components, deb_pulp_distributions, and sanitize methods
  • Ensure content URL is always built for deb repos
app/models/katello/repository.rb
Uniformly apply deb_content_url_options in actions and controllers
  • Replace conditional deb_using_structured_apt? checks with deb? guards
  • Always append deb_content_url_options in content_create, content_update, sync, and finish_upload actions
  • Remove structured-atp branches in destroy, clone_contents, and API controller
app/lib/actions/katello/repository/sync.rb
app/lib/actions/candlepin/product/content_create.rb
app/lib/actions/candlepin/product/content_update.rb
app/lib/actions/katello/repository/destroy.rb
app/lib/actions/katello/repository/clone_contents.rb
app/lib/actions/katello/repository/create.rb
app/lib/actions/katello/repository/finish_upload.rb
app/lib/actions/katello/product/content_create.rb
app/lib/actions/katello/product/content_destroy.rb
app/lib/actions/katello/content_view/refresh_rolling_repo.rb
app/controllers/katello/api/v2/repositories_controller.rb
Add upgrade task to migrate existing APT repos to structured mode
  • Introduce lib/katello/tasks/upgrades/4.19/enable_structured_apt_for_deb.rake
  • Remove old migrate_structure_content_for_deb.rake
lib/katello/tasks/upgrades/4.19/enable_structured_apt_for_deb.rake
Update tests to match mandatory structured APT behavior
  • Remove expectations of deb_using_structured_apt? in tests
  • Assert nil structured/simple flags in publication options
  • Rename and adjust test cases to reflect deb? usage
test/services/katello/pulp3/repository/apt/apt_test.rb
test/actions/katello/repository_test.rb
test/controllers/api/v2/host_subscriptions_controller_test.rb
test/models/product_content_test.rb

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

@quba42 quba42 force-pushed the finalize_structured_apt branch from 8e45624 to 5eb2de4 Compare September 4, 2025 12:10
@maximiliankolb
Copy link
Contributor

FYI: I created a docs PR that is blocked until this is merged: theforeman/foreman-documentation#4215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants