Bug 1541002

Summary: Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
Product: Red Hat Satellite Reporter: Nikhil Kathole <nkathole>
Component: NetworkingAssignee: Marek Hulan <mhulan>
Status: CLOSED ERRATA QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.3.0CC: bbuckingham, bkearney, egolov, lzap, mhulan, mmccune
Target Milestone: 6.4.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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 ----
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-16 19:19:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
log in production.log file
none
screenshot of UI none

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 Satellite Program 2018-07-30 16:19:11 UTC
Upstream bug assigned to mhulan

Comment 10 Satellite Program 2018-07-30 16:19:15 UTC
Upstream bug assigned to mhulan

Comment 11 Satellite Program 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