Skip to content
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

Fixes #38243 - Find a newly registered host correctly in the DB #11324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lfu
Copy link
Member

@lfu lfu commented Feb 26, 2025

What are the changes introduced in this pull request?

Find the newly registered host in the DB correctly to set it into specified organization and location.

Considerations taken when implementing this change?

Host registration is a multiple steps process.
1 It's first stored into DB by registration_manager with default location from setting default_location_subscribed_hosts.
2 Host gets updated by host_fact_importer with default location from setting default_location.
3 Finally Katello prepare_host updates the host with the specified organization and location in the Register Host form.

When a non-admin user registers a host, the host's organization is retrieved from ActivationKey and set correctly.
Its location is set to the value of those two location settings in the first 2 steps and is supposed to be updated to the specified location in step 3.
But Katello::Host::SubscriptionFacet.find_by(uuid: params['uuid'])&.host in step 3 fails to find the newly registered host as it does a scoped search and looks for the host in the specified location from the Register Host form.

The change is this PR would search the host in the whole DB since host id is unique.

What are the testing steps for this pull request?

  1. Create a organization and location, create AK and create a non-admin user with "Register hosts" role
  2. Login with the user and navigate to Hosts -> Register Host, and generate a registration command with created organization and location
  3. Run the registration command on host, and check the host in Satellite webUI in specified organization and location

Before
Host is not present in specified location, instead present in "Default location"

After
Host is present in specified location, instead of "Default location"

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.

1 participant