-
Notifications
You must be signed in to change notification settings - Fork 296
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 #37144 - Use OS family for host details page packages tab #10881
Fixes #37144 - Use OS family for host details page packages tab #10881
Conversation
b04e8b0
to
6d7b6c2
Compare
@jeremylenz We found a bug partly introduced in #10744, here is a proposed fix :) Test failure seems unrelated if I am not mistaken. |
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.
Thanks @nadjaheitmann! Yes, I agree this should be addressed.
I see we're adding an additional API call here. There are a couple other ways this could be accomplished, without adding an API call.
- The host details response already includes
operatingsystem_name
andoperatingsystem_id
. We could addoperatingsystem_family
to that, either (a) via a Foreman code change so other plugins could take advantage; or (b) by extending it from Katello. - The response also already includes
facts
. Foreman uses thedistribution::name
fact to determine the operating system's family. We could look at that fact here as well. (see https://github.com/theforeman/foreman/blob/e87de8d1a30aeba3da6d0cb2518d94aa450db55e/app/services/katello/rhsm_fact_parser.rb#L49-L51)
This was my first attempt. There is
I was actually looking into that one as well, but This is why I finally came up with another API call. |
Also, we need to test the operatingsystem's major version for module streams, so we would also need to expose that one. I agree it would be much simpler if it was part of one API response. |
The problem is that the You can see this by running
and then look at the file CREATE TABLE public.operatingsystems (
id integer NOT NULL,
major character varying(5) DEFAULT ''::character varying NOT NULL,
name character varying(255) NOT NULL,
minor character varying(16) DEFAULT ''::character varying NOT NULL,
nameindicator character varying(3),
created_at timestamp without time zone,
updated_at timestamp without time zone,
release_name character varying(255),
type character varying(255),
description character varying(255),
password_hash character varying(255) DEFAULT 'SHA256'::character varying,
title character varying(255)
); So Rails doesn't add the # app/models/operatingsystem.rb
def family
self[:type]
end
def family=(value)
self.type = value
end To add family to the rabl in Foreman, this would probably work: # app/views/api/v2/hosts/main.json.rabl
node :operatingsystem_family do |host|
host.operatingsystem.family
end Or, to extend it from Katello, I think you could add the same to |
Thanks for the detailed explanation, much appreciated! Do you actually need the operating system family anywhere outside Katello? |
If you're asking where the code should live, I'd be fine with keeping it in Katello. |
Yeah, thanks. I don't get it work in Katello, though. It does not seem to load the No problem to edit the .rabl file directly in Foreman. |
katello/app/controllers/katello/concerns/api/v2/hostgroups_controller_extensions.rb Lines 31 to 35 in 5195646
Hm, maybe you'll need to add something similar to that ^, but in hosts_controller_extensions |
Another thing to try is |
This actually overrides the original template.
This seems to do the trick, thanks! |
40ffd80
to
d9fdf3d
Compare
@jeremylenz Looks much better doesn't 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.
Looking much better 😄
Also tested it and it's working well.
Just a couple small suggestions
@@ -1,9 +1,19 @@ | |||
object @resource | |||
object @host |
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.
object @host |
This seems to not be needed
node :operatingsystem_family do |host| | ||
host.operatingsystem.family | ||
end | ||
|
||
node :operatingsystem_major do |host| | ||
host.operatingsystem.major | ||
end |
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 work also..
node :operatingsystem_family do |host| | |
host.operatingsystem.family | |
end | |
node :operatingsystem_major do |host| | |
host.operatingsystem.major | |
end | |
node :operatingsystem_family do | |
@resource.operatingsystem.family | |
end | |
node :operatingsystem_major do | |
@resource.operatingsystem.major | |
end |
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.
True, fixed
d9fdf3d
to
7a9c083
Compare
Once #10884 is merged let's see how the tests look. LGTM pending green tests. 👍 |
[test katello] |
17c7939
to
b068b4b
Compare
[2024-02-11T22:26:17.378Z] Error: Looks like a fixture cannot be found in foreman itself. Any idea how to fix this? |
b068b4b
to
6ec24ad
Compare
I don't even see how fixtures are being used -- that test uses FactoryBot, anyway. See if a rebase fixes it maybe? 🤔 |
6ec24ad
to
fed0b38
Compare
Now the katello test is green, it was one commit I have added - seems fishy... New failure though, which I assume is not related: Failure: |
I re-ran that check and it's green now. Was just an array ordering failure that we get intermittently. ✔️ |
The React failure is unrelated |
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.
…llo#10881) (cherry picked from commit f14f58e)
…llo#10881) (cherry picked from commit f14f58e)
What are the changes introduced in this pull request?
At the moment, the packages sub tab on the new host details page is shown based on the description of the operating system (e.g. checking whether it should load rpm or debs). The condition checks for various strings, but the description itself can be randomly assigned by the user. Hence, this is not a safe method to determine which OS was used.
Considerations taken when implementing this change?
We need to find an unchangeable attribute to test against for the content packages tabs which is the operatingsystem family.
What are the testing steps for this pull request?
Have a host with packages and some OS. Change OS name to something like "Test OS" --> Host packages should still be available.