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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #23706 - CV/LE show the right value on Host form #7398
Conversation
|
Issues: #23706 |
|
Makes sense to me, hostgroup already implements both methods (via hostgroup extensions), reporter confirms it fixes the issue, 馃憤 from me |
|
@dLobatog the test failure is related |
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.
@ares Updated, had to jump through some hoops to get the test passing, just some differences between working with FactoryBot vs real models saved in the db.
| @@ -26,6 +29,8 @@ def test_accessible_lifecycle_environments | |||
| end | |||
|
|
|||
| def test_accessible_lifecycle_environments_limited | |||
| @host.save | |||
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.
Had to do this so I could call @host.lifecycle_environment later..
On the test environment with FactoryBot.build it doesn't work as the association needs to be saved in the database to work: https://github.com/Katello/katello/blob/master/app/models/katello/concerns/content_facet_host_extensions.rb#L29
|
could some committer take a look and merge if ACKed? |
|
@parthaa Can you take a look? |
|
@dLobatog this doesn't seem to fix the issue? at least i can reproduce it as described:
|
| @@ -77,20 +61,19 @@ def kickstart_repository_id(host, options = {}) | |||
| end | |||
|
|
|||
| def fetch_lifecycle_environment(host, options = {}) | |||
| return host.lifecycle_environment if host.lifecycle_environment.present? | |||
| selected_host_group = options.fetch(:selected_host_group, nil) | |||
| return lifecycle_environment(selected_host_group) if selected_host_group.present? | |||
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 like you deleted the lifecycle_environment method above:
undefined method `lifecycle_environment' for #<#Class:0x0000000bb7e3e0:0x0000000bb8ed58>
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.
this seems to happen if you create a host, select the host group, but don't select a CV or LCE. Then go to the host edit page.
It does seem to solve the original issue thou gh.
| end | ||
|
|
||
| def fetch_content_view(host, options = {}) | ||
| return host.content_view if host.content_view.present? | ||
| selected_host_group = options.fetch(:selected_host_group, nil) | ||
| return content_view(selected_host_group) if selected_host_group.present? |
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.
This method has been deleted as well. This line needs to change too
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.
@parthaa @jlsherrill Updated to fix the calls to the removed method
Before this patch, the following situation could happen: 1. Host A is part of a Host Group 'test'. Host A inherits LE/CV 'test' coming from Host Group 'test' 2. We decide to change the LE/CV of Host A to 'production', either through the API or the UI. 3. The next time we decide to check the UI, the helper was wrong (this patch fixes it) and showed the LE/CV from the Host Group 'test'. This is very confusing and may even cause you to change the LE/CV to from 'production' to 'test' by accident.
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.
@jlsherrill @parthaa Green tests 馃槃
If you could take a look again it'd be great, it's really bothering the people who opened the BZ (it has several cases attached as you may see).
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.
It works as expected, though I noticed this scenario:
- create a host
- assign a CV/LE and save, leaving hostgroup empty
- edit the host, select a host group
At this point, I can't clear the CV or LE without incurring validation errors. There doesn't seem to be a way to tell Foreman to use the CV/LE associated with the host group. This is kind of a contrived scenario, but users may encounter it. What do you think? @jlsherrill had mentioned to me that we might think about something like the inherit button we use for the puppet fields.
|
@akofink i agree, but i think we might should open a 2nd issue for that? This would be a better change for the near term and less risky to backport to older releases. Thoughts? |
|
I'm good with that. I'll file an issue for it. |
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.
ACK from me! Thanks @dLobatog!

Before this patch, the following situation could happen:
Host A is part of a Host Group 'test'. Host A inherits LE/CV 'test'
coming from Host Group 'test'
We decide to change the LE/CV of Host A to 'production', either
through the API or the UI.
The next time we decide to check the UI, the helper was wrong (this
patch fixes it) and showed the LE/CV from the Host Group 'test'. This is
very confusing and may even cause you to change the LE/CV to from
'production' to 'test' by accident.
In my opinion this should be backported to 3.6 at least
馃帴
Before: https://webmshare.com/q5g6Q
After: https://webmshare.com/mPa3D