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 BZ#2238952 - Selecting host group change form URL #609

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

stejskalleos
Copy link
Contributor

Fixed issue:

  • Go to discovered hosts
  • Select provision > Customize
  • Select hostgroup
  • Create host

Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

While this could work, I think we should try and fix the root cause to f this problem. I think it comes form the fact that hosts_path override does not take into account hostgroup replacement use case.

@stejskalleos stejskalleos force-pushed the ls/hosts_url branch 2 times, most recently from b44b52e to 117222b Compare November 13, 2023 14:38
Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

Looks quite good, kudos for documentation! a couple of readability comments:

I would reverse the conditions of the method though:

return discovered_host if controller == 'discovered_hosts'
return discovered_host if controller == 'hosts' && action == 'hostgroup' && Host::Discovered.exists?(id)
super

I think it's a bit more readable.
Also I would use exists? instead of find_by , it's much less memory consuming:
https://api.rubyonrails.org/v6.1.3/classes/ActiveRecord/FinderMethods.html#method-i-exists-3F

# The hostgroup onChange action is replacing the form url from `/discovered_hosts/:id`
# to `/hosts/:id``, which is not correct (in this case) and it breaks the form submission
return discovered_host_path(host) if controller_name == 'hosts' &&
action_name == 'process_hostgroup' &&
Copy link
Member

Choose a reason for hiding this comment

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

While I'm OK with specifying this particular method as it's the one that causes the bug, I wonder if we shouldn't include all the AJAX methods from the controller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but I'm worried about the impact it can have across the plugins. This fix is right now important for downstream release, can we go with it as it is and later on think about the refactoring? Dont want to block QAs who are waiting for this fix.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good for me. Let's start with this, and deal with the fallout later.

Copy link
Contributor

@nofaralfasi nofaralfasi left a comment

Choose a reason for hiding this comment

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

I didn't test it because I don't have the required setup, but the changes look good to me.

Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

Didn't test it, but ACK from me.
Just make sure the tests are green before the merge!

@stejskalleos
Copy link
Contributor Author

The CI is broken, but not because of the changes in this PR, it's been red for a while.
The packit build is broken as well, I can't send the rpm to QEs for confirmation before the merge.
The safe conditions are pretty strict, I tested it, but let's get this in and see if QAs will be happy with it.

@ShimShtein @nofaralfasi

@stejskalleos stejskalleos merged commit f58270b into theforeman:develop Nov 22, 2023
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants