Project

General

Profile

Bug #24478

Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass

Added by Marek Hulán 5 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Network
Target version:
-
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1541002

Description of problem: Trying to delete subnet which is used by provisioned host gives error

2018-02-01 08:40:36 c64b0466 [app] [W] Action failed | NoMethodError: undefined method `klass' for nil:NilClass | Did you mean? class | /opt/theforeman/tfm/root/usr/share/gems/gems/scoped_search-4.1.2/lib/scoped_search/query_builder.rb:31:in `class_for' | /opt/theforeman/tfm/root/usr/share/gems/gems/scoped_search-4.1.2/lib/scoped_search/query_builder.rb:18:in `build_query' | /usr/share/foreman/app/services/authorizer.rb:96:in `build_filtered_scope_components' | /usr/share/foreman/app/services/authorizer.rb:55:in `find_collection' | /usr/share/foreman/app/models/concerns/authorizable.rb:27:in `authorized_as' | /usr/share/foreman/app/models/concerns/authorizable.rb:65:in `authorized' | /usr/share/foreman/app/services/association_authorizer.rb:10:in `authorized_associations' | /usr/share/foreman/lib/core_extensions.rb:45:in `block (2 levels) in before_destroy' | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `each' | /opt/rh/rh-ror42/root/usr/share/gems/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:46:in `each' | /usr/share/foreman/lib/core_extensions.rb:42:in `block in before_destroy' | /usr/share/foreman/lib/core_extensions.rb:41:in `each'

Version-Release number of selected component (if applicable): Satellite 6.3 snap 34

How reproducible: always

Steps to Reproduce:
1. Create subnet
2. Provision a host using created subnet
3. Try to delete subnet

Actual results:

Error as Oops, we're sorry but something went wrong undefined method `klass' for nil:NilClass Did you mean? class

and production.log showed 500 internal server error (see attachment).

Expected results: It should show warning as "subnet is used by host"

Additional info: It is regression. Working correctly in 6.2.14.


Related issues

Related to Foreman - Bug #25207: Invalid single-table inheritance type: Host::Discovered is not a subclass of Host::ManagedClosed

Associated revisions

Revision 3a228ed7 (diff)
Added by Marek Hulán 5 months ago

Fixes #24478 - properly sanitize class name

Revision 4a5cec5a (diff)
Added by Marek Hulán 3 months ago

Fixes #24478 - properly sanitize class name

History

#1 Updated by The Foreman Bot 5 months ago

  • Assignee set to Marek Hulán
  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5888 added

#2 Updated by Marek Hulán 5 months ago

  • Status changed from Ready For Testing to Closed

#3 Updated by Tomer Brisker 4 months ago

  • Subject changed from Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass to Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
  • Fixed in Releases 1.19.0, 1.20.0 added

#4 Updated by Tomer Brisker 4 months ago

  • Fixed in Releases deleted (1.19.0)

#5 Updated by Tomer Brisker 4 months ago

  • Status changed from Closed to Assigned
  • Fixed in Releases deleted (1.20.0)

The fix broken discovery plugin and was reverted. Returning to assigned state.

#6 Updated by The Foreman Bot 3 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/6053 added

#7 Updated by Ondřej Pražák 3 months ago

  • Status changed from Ready For Testing to Closed
  • Fixed in Releases 1.20.0 added

#8 Updated by Lukas Zapletal about 2 months ago

  • Related to Bug #25207: Invalid single-table inheritance type: Host::Discovered is not a subclass of Host::Managed added

Also available in: Atom PDF