Bug #16750

*_selected methods expect params[:host] to exist

Added by Daniel Lobato Garcia 7 months ago. Updated 5 months ago.

Status:Closed
Priority:High
Assigned To:Daniel Lobato Garcia
Category:Discovery plugin
Target version:Plugin 7.0.1
Difficulty: Pull request:https://github.com/theforeman/foreman_discovery/pull/304
Bugzilla link:1397367
Story points-
Velocity based estimate-

Description

Due to the strong params changes, the methods we override in routes.rb (architecture_selected, os_selected, medium_selected) do not longer work.
The reason is that these *_selected methods expect params[:host] to exist. Other methods like 'taxonomy_scope' also expect params[:host] to exist.
However, 'discovered_hosts/edit' sends params[:discovered_host], which is not understood by the HostController.

The discovery plugin should realize that these params will not be understood by HostController and change them appropriately.

This blocks discovery provisioning without choosing a hostgroup.

Associated revisions

Revision abde986e
Added by Daniel Lobato Garcia 5 months ago

Fixes #16750 - *_selected methods expect params[:host]

Due to the strong params changes, the methods we override in routes.rb
(architecture_selected, os_selected, medium_selected) do not longer
work.

The reason is that these *_selected methods expect params[:host] to
exist. Other methods like 'taxonomy_scope' also expect params[:host] to
exist.

However, 'discovered_hosts/edit' sends params[:discovered_host], which
is not understood by the HostController.

The discovery plugin should realize that these params will not be
understood by HostController and change them appropriately.

This patch merely checks the URL and if it matches 'discovered_hosts' in
some place, it will also set params[:host].

History

#1 Updated by Daniel Lobato Garcia 7 months ago

The error that throws is

NoMethodError: undefined method `has_key?' for nil:NilClass
app/controllers/concerns/foreman/controller/parameters/keep_param.rb:11:in `block in keep_param'

That's coming from app/controller/s/concern/foreman/controller/parameters/host.rb , which calls `host_params` with `top_level_hash = 'host'`. Then `keep_param` tries to access 'params['host']` and fails.

#2 Updated by The Foreman Bot 7 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman_discovery/pull/304 added

#3 Updated by Lukas Zapletal 5 months ago

  • Target version set to Plugin 7.0.1

Just in time for .1 thanks! :-)

#4 Updated by Lukas Zapletal 5 months ago

  • Bugzilla link set to 1397367

#5 Updated by Anonymous 5 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF