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 #36498 - Don't try to unset a host's CV/LCE when inheriting from hostgroup #10595

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

jeremylenz
Copy link
Member

@jeremylenz jeremylenz commented Jun 9, 2023

What are the changes introduced in this pull request?

Redefines Foreman's apply_inherited_attributes method (from Host::Managed) to address the case where either content_view_id or lifecycle_environment_id are blank. Since they must now be provided together, having a hostgroup where only one of them is set causes problems.

Considerations taken when implementing this change?

This whole issue should go away once we make the same multi-CV changes to Hostgroup::ContentFacet that have already been made to Host::ContentFacet.

What are the testing steps for this pull request?

Create a hostgroup with CV and LCE
Edit the hostgroup and remove the LCE (click the X)
Go to one of your hosts and click Edit
Assign the host to the hostgroup and click Submit

Before patch: an error content_view_id and lifecycle_environment_id must be provided together
After patch: no errors

Click around other host and hostgroup edit flows and make sure nothing is broken

  • host assigned to hostgroup with no CV and no LCE
  • host assigned to hostgroup with both CV and LCE
  • host not assigned to hostgroup

@theforeman-bot
Copy link

Issues: #36498

return attributes if facet_attrs.blank?
cv_id = facet_attrs['content_view_id']
lce_id = facet_attrs['lifecycle_environment_id']
if initialized && (cv_id.blank? || lce_id.blank?)
Copy link
Member Author

Choose a reason for hiding this comment

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

If both cv_id and lce_id are blank, what then?

I considered adding explicit logic for this. But I think we're okay without it, because the two cases are

  1. Host with content facet: will already have a valid LCE and CV, and the host will use its existing values
  2. Host without content facet: facet_attrs will be nil, meaning this code path isn't touched

anyway, I couldn't get it to error in my testing. But let me know if I'm wrong :D

Copy link
Member

@ianballou ianballou left a comment

Choose a reason for hiding this comment

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

Working fine for me!

@jeremylenz jeremylenz merged commit 08941da into Katello:master Jun 16, 2023
4 of 5 checks passed
lfu pushed a commit to lfu/katello that referenced this pull request Jun 21, 2023
…m hostgroup (Katello#10595)

* Fixes #36498 - Don't try to unset a host's CV/LCE when inheriting from hostgroup

* Refs #36498 - fix test

(cherry picked from commit 08941da)
lfu pushed a commit that referenced this pull request Jun 21, 2023
…m hostgroup (#10595)

* Fixes #36498 - Don't try to unset a host's CV/LCE when inheriting from hostgroup

* Refs #36498 - fix test

(cherry picked from commit 08941da)
wbclark pushed a commit to wbclark/katello that referenced this pull request Sep 7, 2023
…m hostgroup (Katello#10595)

* Fixes #36498 - Don't try to unset a host's CV/LCE when inheriting from hostgroup

* Refs #36498 - fix test

(cherry picked from commit 08941da)
wbclark pushed a commit that referenced this pull request Sep 27, 2023
…m hostgroup (#10595)

* Fixes #36498 - Don't try to unset a host's CV/LCE when inheriting from hostgroup

* Refs #36498 - fix test

(cherry picked from commit 08941da)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants