Fixes #38243 - Find a newly registered host correctly in the DB #11324
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theRegister 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?
Before
Host is not present in specified location, instead present in "Default location"
After
Host is present in specified location, instead of "Default location"