Bug 1541002 - Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
Summary: Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Networking
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium vote
Target Milestone: 6.4.0
Assignee: Marek Hulan
QA Contact: Nikhil Kathole
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-01 13:57 UTC by Nikhil Kathole
Modified: 2019-11-05 23:12 UTC (History)
6 users (show)

Fixed In Version: foreman-1.18.0.26-1
Doc Type: Known Issue
Doc Text:
*Known Issue* If you try to delete a subnet that is used to provision a machine, instead of receiving a user-friendly error message, you receive a confusing error message: ---- | NoMethodError: undefined method `klass' for nil:NilClass | Did you mean? class ----
Clone Of:
Environment:
Last Closed: 2018-10-16 19:19:30 UTC
Target Upstream Version:


Attachments (Terms of Use)
log in production.log file (17.87 KB, text/plain)
2018-02-01 13:57 UTC, Nikhil Kathole
no flags Details
screenshot of UI (19.76 KB, image/png)
2018-02-01 13:57 UTC, Nikhil Kathole
no flags Details


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 24478 None None None 2018-07-30 14:07:57 UTC

Description Nikhil Kathole 2018-02-01 13:57:04 UTC
Created attachment 1389513 [details]
log in production.log file

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.

Comment 1 Nikhil Kathole 2018-02-01 13:57:32 UTC
Created attachment 1389514 [details]
screenshot of UI

Comment 2 Nikhil Kathole 2018-02-01 15:03:21 UTC
Changes in reproducible steps:

1. Create user with role cloning organization_admin role
2. Login with created user
3. Create subnet
4. Provision a host using created subnet
5. Try to delete subnet

Additional info :
Removing regression as not sure about it.

Comment 7 Marek Hulan 2018-07-30 14:07:55 UTC
Created redmine issue https://projects.theforeman.org/issues/24478 from this bug

Comment 9 pm-sat@redhat.com 2018-07-30 16:19:11 UTC
Upstream bug assigned to mhulan@redhat.com

Comment 10 pm-sat@redhat.com 2018-07-30 16:19:15 UTC
Upstream bug assigned to mhulan@redhat.com

Comment 11 pm-sat@redhat.com 2018-08-02 15:57:53 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/24478 has been resolved.

Comment 13 Lukas Zapletal 2018-08-28 13:54:01 UTC
Regressions were found in discovery, we are reverting the patch from Satellite 6.4.

Comment 15 Nikhil Kathole 2018-09-06 16:51:11 UTC
FailedQA

# rpm -q foreman
foreman-1.18.0.18-1.el7sat.noarch

# rpm -q satellite
satellite-6.4.0-13.el7sat.noarch

Can see same error.
 
No changes as per PR. (As per comment #13, PR is reverted)

Comment 18 Nikhil Kathole 2018-09-17 09:26:18 UTC
VERIFIED

Version tested:
Satellite 6.4 snap 22

Expected warning as $subnet is used by lola-borges.host.domain, $subnet is used by RHEL 7 Server 64-bit HG, $subnet is used by RHEL 6 Server 64-bit HG, $subnet is used by lola-borges.host.domain, and foreman is used by host.domain

Comment 19 Bryan Kearney 2018-10-16 19:19:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:2927


Note You need to log in before you can comment on or make changes to this bug.