-
Notifications
You must be signed in to change notification settings - Fork 297
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 #36897 - Hosts now follow existing facet standards for hostgroup inheritance #10841
Conversation
7de54cb
to
d09f8f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a proper review, just some coding style things I noticed.
Just made some big changes after a few meetings with the team. Will update PR description later today. |
@parthaa This should be good for review. Jeremy suggested you could get a head start while I work on the test cases. |
… inheritance This is a complicated topic; more info in Katello PR Katello#10841. Added logic to have host edit form always return values for CV and LE, regardless of whether they can be edited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good as far as facets/hostgroup relations go.
I wonder if this also addresses https://projects.theforeman.org/issues/35215, since we're now ensuring that the host form sends existing values for CV/LCE. |
Changes here are good. Couple of issues I found
Recommended Patch diff --git a/app/models/katello/concerns/hostgroup_extensions.rb b/app/models/katello/concerns/hostgroup_extensions.rb
index e08b8d07ae..9966e7c8a7 100644
--- a/app/models/katello/concerns/hostgroup_extensions.rb
+++ b/app/models/katello/concerns/hostgroup_extensions.rb
@@ -122,7 +122,7 @@ module Katello
# it will return the value 2.
facet_model = Facets.registered_facets[facet].hostgroup_configuration.model
value = facet_model.where.not(attribute => nil).joins(:hostgroup).merge(
- ::Hostgroup.where(id: self.ancestor_ids).reorder(ancestry: :desc)
+ ::Hostgroup.where(id: self.ancestor_ids).reorder("#{::Hostgroup.table_name}.ancestry desc nulls last")
).pick(attribute)
end
value |
… inheritance This is a complicated topic; more info in Katello PR Katello#10841. Added logic to have host edit form always return values for CV and LE, regardless of whether they can be edited.
Thanks for the fix @parthaa; I just pushed it through. I finally had some time to repair the broken test cases so we should be go to go here provided testing passes. |
🙈 |
… inheritance This is a complicated topic; more info in Katello PR Katello#10841. Added logic to have host edit form always return values for CV and LE, regardless of whether they can be edited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested inheritance of host groups (4 levels) and they worked as desired,
Nice work @qcjames53 and @jeremylenz !
Thank you @ShimShtein for your guidance :)
APJ
… inheritance This is a complicated topic; more info in Katello PR Katello#10841. Added logic to have host edit form always return values for CV and LE, regardless of whether they can be edited.
SAT-21776 Describe which settings get updated upon host group change Use code blocks for NOTE Update guides/common/modules/proc_creating-a-host.adoc Co-authored-by: Brian Angelica <91690569+bangelic@users.noreply.github.com> Update capitalization for CV and LCE Simplify a sentence Update capitalization of host group CV and LCE are now inherited upon host group change Katello/katello#10841 Updated host details after host group change moved to Verification
… inheritance This is a complicated topic; more info in Katello PR Katello#10841. Added logic to have host edit form always return values for CV and LE, regardless of whether they can be edited. (cherry picked from commit a896b2f)
What are the changes introduced in this pull request?
This was a rather simple bug which exposed some not so simple issues in Katello's handing of host group -> host inheritance. More details on this process in the consideration section...
Hosts will now always inherit the lifecycle environment and the content view from their host group on creation and update. This matches the behavior of other attributes in Foreman. In order to prevent the LE and CV from 'resetting' on an update, the user will now have to manually specify the LE and CV in the properties of the host.
The 'Edit host' form now contains hidden fields to prevent the LE and CV from 'resetting' on an update. These fields duplicate the disabled but still visible dropdowns menus on host edit, allowing the LE and CV info to still be sent in the PATCH request.
Considerations taken when implementing this change?
This bug involved quite a large amount of archeology. Big thanks to @jeremylenz and @ShimShtein for their help with this.
Host update in Katello needs to be handled in a roundabout fashion due to some of the ways ActiveRecord stores the LE and CV info. These fields need to be given to the controller as a
host.content_facet.lifecycle_environment_id
property, but are stored in ActiveRecord differently to account for multi CV support in the future. A consequence of this was that LE and CV ids needed to be cleared from the attributes of the ActiveRecord request before save, or else the model would throw errors.Katello was implementing this parameter deletion twice, once before and once during host update. The original bug of 'resetting' CV and LEs stemmed from the implementation of facet inheritance on the Foreman side: any property not explicitly set on an update or create is allowed to be overriden by the host group's property. When we were deleting the CV and LE params before the host update, facet inheritance was automatically overriding these with the host group's CV and LE. By keeping these params until midway through the host update, we can appease both the facet inheritance and the ActiveRecord sides of this issue.
What are the testing steps for this pull request?
Hosts that inherit LE from one hostgroup and CV from another
Hosts that only inherit LE from a hostgroup
Creating / updating hosts using hammer and the API
Update 2024-01-11: Reworded changes introduced description.
Update 2024-01-19: Reworked PR to integrate existing facet inheritance scheme in Foreman.