Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1541002 - Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
Unable to delete subnet NoMethodError: undefined method `klass' for nil:NilClass
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Networking (Show other bugs)
6.3.0
Unspecified Unspecified
unspecified Severity medium (vote)
: 6.3.4
: Unused
Assigned To: Marek Hulan
Nikhil Kathole
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2018-02-01 08:57 EST by Nikhil Kathole
Modified: 2018-10-16 15:19 EDT (History)
6 users (show)

See Also:
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 15:19:30 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 24478 None None None 2018-07-30 10:07 EDT

  None (edit)
Description Nikhil Kathole 2018-02-01 08:57:04 EST
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 08:57 EST
Created attachment 1389514 [details]
screenshot of UI
Comment 2 Nikhil Kathole 2018-02-01 10:03:21 EST
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 10:07:55 EDT
Created redmine issue https://projects.theforeman.org/issues/24478 from this bug
Comment 9 pm-sat@redhat.com 2018-07-30 12:19:11 EDT
Upstream bug assigned to mhulan@redhat.com
Comment 10 pm-sat@redhat.com 2018-07-30 12:19:15 EDT
Upstream bug assigned to mhulan@redhat.com
Comment 11 pm-sat@redhat.com 2018-08-02 11:57:53 EDT
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 09:54:01 EDT
Regressions were found in discovery, we are reverting the patch from Satellite 6.4.
Comment 15 Nikhil Kathole 2018-09-06 12:51:11 EDT
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 05:26:18 EDT
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 15:19:30 EDT
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.