Skip to content

Fixes #38440 - Preserve candlepin content when deleting rolling repo clone with structured apt #11399

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

Merged

Conversation

quba42
Copy link
Contributor

@quba42 quba42 commented May 26, 2025

Draft PR until I have added test coverage.

Summary by Sourcery

Prevent ContentDestroy for rolling structured APT repository clones and ensure content removal only applies to non-rolling structured APT or last-instance repos.

Bug Fixes:

  • Skip Candlepin content deletion for structured APT repo clones in rolling content views by checking content_view.rolling? before planning ContentDestroy.

Tests:

  • Add test to confirm content is destroyed for structured APT repository clones in non-rolling views.
  • Add test to confirm content is retained for structured APT repository clones in rolling views.

Copy link

sourcery-ai bot commented May 26, 2025

Reviewer's Guide

This PR tightens the repository destroy action so that structured APT clones in rolling content views no longer trigger ContentDestroy, and adds unit tests to verify both the removal and retention behaviors.

File-Level Changes

Change Details Files
Skip content destruction for structured APT repos in rolling views
  • Augment handle_custom_content condition to include !content_view.rolling?
  • Wrap deb_using_structured_apt? check with rolling view guard
  • Plan ContentDestroy only when structured APT and view is non-rolling
app/lib/actions/katello/repository/destroy.rb
Add tests for structured APT content removal and retention
  • Assert ContentDestroy is planned for structured APT in non-rolling views
  • Refute ContentDestroy for structured APT in rolling views
test/actions/katello/repository_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 fix_structured_apt_rolling_cv_delete branch from d014706 to 299c3b5 Compare May 26, 2025 16:22
@quba42 quba42 marked this pull request as ready for review May 26, 2025 16:22
@quba42
Copy link
Contributor Author

quba42 commented May 26, 2025

Added test coverage.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @quba42 - I've reviewed your changes - here's some feedback:

  • The combined condition in handle_custom_content is a bit dense; consider extracting (repository.deb_using_structured_apt? && !repository.content_view.rolling?) into a well-named predicate method to improve readability.
  • There's a typo in the test helper method refute_action_planed (should be refute_action_planned), which could lead to confusion or silent failures.
  • Consider adding a test for a structured APT repo in a rolling view when remove_from_content_view_versions is explicitly set to true to ensure the removal flag overrides the rolling logic as expected.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from 299c3b5 to 6455dc7 Compare May 26, 2025 16:29
@quba42
Copy link
Contributor Author

quba42 commented May 26, 2025

Fixed rubocop/lint error.

@quba42 quba42 changed the title Fixes #38440 - Do not delete candlepin content when deleting a rolling repo clone of a structured apt deb repository Fixes #38440 - Preserve candlepin content when deleting rolling repo clone with structured apt May 26, 2025
Copy link
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

action.stubs(:action_subject).with(clone)
action.expects(:plan_self)
plan_action action, clone
refute_action_planed action, ::Actions::Katello::Product::ContentDestroy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo in the test helper method refute_action_planed (should be refute_action_planned), which could lead to confusion or silent failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found several more instances of refute_action_planed in the existing tests in this file. For now I have decided to fix them all as part of my commit.

Btw: Fixing these typos had no apparent effect on running the tests locally (still green and same number of passed assetions as before). It looks like both spellings are somehow understood?

If I should only fix the typo in my new test (but not the existing tests in the file) instead let me know.

Copy link
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments

@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from 6455dc7 to fa3118c Compare June 2, 2025 12:45
@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from fa3118c to faf4738 Compare June 2, 2025 12:53
@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from faf4738 to 4d5e2b7 Compare June 3, 2025 10:08
@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from 4d5e2b7 to 5d47997 Compare June 4, 2025 12:02
@quba42
Copy link
Contributor Author

quba42 commented Jun 5, 2025

In the hope of unblocking this PR: My gut feeling is that it is better to drop the fixup commit from this branch. My argument is mainly that I think this will make the history more readable (if we need to change the relevant lines 6 Months from now).

That being said, I don't feel very strongly about this, so if others disagree, I am fine with squishing things together and going with this version as well.

@quba42 quba42 requested a review from chris1984 June 5, 2025 09:16
@quba42 quba42 force-pushed the fix_structured_apt_rolling_cv_delete branch from 5d47997 to ce5846d Compare June 5, 2025 14:45
Copy link
Contributor

@m-bucher m-bucher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments have been addressed and code looks good to me.
@chris1984, @sjha4 any things left preventing this from being merged?

Copy link
Member

@sjha4 sjha4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack 👍🏼

@m-bucher m-bucher dismissed chris1984’s stale review June 18, 2025 12:10

Comments were addressed.

@m-bucher m-bucher merged commit 1a793ac into Katello:master Jun 18, 2025
19 checks passed
@m-bucher m-bucher deleted the fix_structured_apt_rolling_cv_delete branch June 18, 2025 12:12
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.

4 participants