Skip to content

Conversation

parthaa
Copy link
Contributor

@parthaa parthaa commented Sep 5, 2025

What are the changes introduced in this pull request?

This pr adds methods to delay index and other organization controller actions so that those actions work with RH cloud properly setup

Considerations taken when implementing this change?

The foreman_rh_cloud plugin overwrites the list of methods that run local_find_taxonomy as a before_action in the Organizations controller: https://github.com/theforeman/foreman_rh_cloud/pull/1003/files#diff-d703d9179cea9d0d9bb78f9d6a1028620c7d4270479ebed553223bf4826ddc3dR227

Changed it to work via a yield mechanism

What are the testing steps for this pull request?

  • Start katello with foreman rh cloud
  • run this hammer command
$ hammer organization configure-cdn --id 1 --type redhat_cdn --url "https://cdn.redhat.com" ```

Before Applying this PR and RH Cloud PR

Could not update CDN configuration.:
Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs.


After Applying this PR and RH Cloud PR

CDN Configuration Updated


## Summary by Sourcery

Enable postponing of specific before_action filters in Katello API controllers to ensure compatibility with the RH Cloud plugin

Enhancements:
- Extract index and taxonomy action lists into INDEX_ACTIONS and LOCAL_FIND_TAXONOMY_ACTIONS constants
- Add delay_index_actions and delay_find_taxonomy_actions methods to temporarily skip and reapply before_action filters

Copy link

sourcery-ai bot commented Sep 5, 2025

Reviewer's Guide

This PR refactors Katello’s API controllers by extracting repeated before_action targets into constants and introducing yield-based class methods to temporarily skip and reapply those filters, enabling the foreman_rh_cloud plugin to delay organization/product and taxonomy lookups as needed.

File-Level Changes

Change Details Files
Refactor index-related filters and add delay_index_actions in RepositoriesController
  • Extracted index and auto_complete_search into INDEX_ACTIONS constant
  • Updated before_action calls to reference INDEX_ACTIONS
  • Added class method delay_index_actions to skip and reapply find_optional_organization and find_product around a yield
app/controllers/katello/api/v2/repositories_controller.rb
Refactor taxonomy lookup filter and add delay_find_taxonomy_actions in OrganizationsController
  • Extracted taxonomy-related actions into LOCAL_FIND_TAXONOMY_ACTIONS constant
  • Updated before_action to use LOCAL_FIND_TAXONOMY_ACTIONS
  • Added class method delay_find_taxonomy_actions to skip and reapply local_find_taxonomy around a yield
app/controllers/katello/api/v2/organizations_controller.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

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 there - I've reviewed your changes and they look great!


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.


resource_description do
api_version 'v2'
api_base_url "/katello/api"
end

def self.delay_find_taxonomy_actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def self.delay_find_taxonomy_actions
def self.before_find_taxonomy_actions

will read better when used:

        Katello::Api::V2::OrganizationsController.before_find_taxonomy_actions do
          Katello::Api::V2::OrganizationsController.add_smart_proxy_filters(
            [:index, :download_debug_certificate],
            features: ForemanRhCloud.on_prem_smart_proxy_features
          )
        end

@@ -35,6 +35,15 @@ class Api::V2::RepositoriesController < Api::V2::ApiController # rubocop:disable
skip_before_action :authorize, :only => [:gpg_key_content]
skip_before_action :check_media_type, :only => [:upload_content]

def self.delay_index_actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto:

Suggested change
def self.delay_index_actions
def self.before_index_actions

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.

2 participants