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 #30375 - fix os_minor search to not show empty minor #7816

Merged
merged 1 commit into from
Jul 27, 2020

Conversation

shiramax
Copy link
Contributor

The issue:
when we search for os_minor < 0, all hosts with empty minor versions are shown.

app/models/concerns/hostext/search.rb Outdated Show resolved Hide resolved
app/models/concerns/hostext/search.rb Outdated Show resolved Hide resolved
app/models/concerns/hostext/search.rb Outdated Show resolved Hide resolved
app/models/concerns/hostext/search.rb Outdated Show resolved Hide resolved
@theforeman-bot
Copy link
Member

Issues: #30375

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Looks good, just one nitpick, feel free to disagree with it 🙃

if os_y.to_i.public_send(operator + operator_addition1, y.to_i)
if os_y == y
if os_z.to_i.public_send(operator + operator_addition2, z.to_i)
unless os.minor.empty?
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't this be better and save us the additional indentation?

Suggested change
unless os.minor.empty?
next if os.minor.empty?

Just a nitpick, I know I'm bit of a indentation freak 🤦 xD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :) thansk! @ezr-ondrej

@ezr-ondrej
Copy link
Member

Comment on lines 237 to 238
Operatingsystem.all.find_each do |os|
next if os.minor.empty?
Copy link
Member

Choose a reason for hiding this comment

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

You can pre-filter the empty ones when pulling them from the db

Suggested change
Operatingsystem.all.find_each do |os|
next if os.minor.empty?
Operatingsystem.where.not(minor: nil).find_each do |os|

Copy link
Member

Choose a reason for hiding this comment

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

Unless minor can be '' empty string, I thing this is better solution :)

Copy link
Member

Choose a reason for hiding this comment

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

how about:

Suggested change
Operatingsystem.all.find_each do |os|
next if os.minor.empty?
Operatingsystem.where.not(minor: [nil, '']).find_each do |os|

Copy link
Member

Choose a reason for hiding this comment

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

Unless minor can be '' empty string, I thing this is better solution :)

I think we should think about empty strings, but it's a bigger effort. Debian doesn't really have minor versions anymore. It used to really have supported minor versions but now a minor is just a roll up of patches to a release. Also with CentOS there are no supported minors (only the latest). Unless you sync content, you can't really install an older minor version.

tl;dr: the Foreman model is complex, may not match reality anymore, needs discussion with whiteboards and/or beer

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the whole inventory would deserve a brainstorm session, but definitely out of scope of this PR.

@ezr-ondrej
Copy link
Member

[test katello] is broken again

Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Thanks @shiramax! 👍
And thanks @tbrisker and @ekohl :)

@ezr-ondrej ezr-ondrej merged commit baf7b51 into theforeman:develop Jul 27, 2020
@tbrisker
Copy link
Member

2.1- 9a917db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants