Bug 840969 - Delete environment with members causes Couldn't find KTEnvironment with
Delete environment with members causes Couldn't find KTEnvironment with
Status: CLOSED ERRATA
Product: Subscription Asset Manager
Classification: Red Hat
Component: katello (Show other bugs)
1.1.0
Unspecified Unspecified
high Severity high
: rc
: 1.2
Assigned To: Jordan OMara
Tazim Kolhar
:
Depends On:
Blocks: 840970 858365
  Show dependency treegraph
 
Reported: 2012-07-17 13:59 EDT by Eric Sammons
Modified: 2016-04-25 20:54 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 840970 858365 (view as bug list)
Environment:
Last Closed: 2013-02-21 14:16:50 EST
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)
Default Organisation removed (43.73 KB, image/png)
2012-10-10 05:48 EDT, Tazim Kolhar
no flags Details

  None (edit)
Description Eric Sammons 2012-07-17 13:59:14 EDT
Description of problem:
As a sysadmin I should not be able to delete an environment with user members (users that have the environment set has their default).

Deleting an environment where users have set the environment as their default will lead to the environments tab under user preferences being inaccessible.

Version-Release number of selected component (if applicable):
sam-1.1

Steps to Reproduce:
1. Create environments under an org
2. Navigate to user preferences
3. Navigate to the Environments tab under user preferences
4. Assign the default org and environment as set up in step 1.
5. Return to the orgs tab
6. delete the environment set in step 1.
7. Return to user preferences
8. select user and navigate to environments tab
  
Actual results:
Tab is inaccessible.

---production.log
[ERROR: 2012-07-17 13:56:27 #12589] ActiveRecord::RecordNotFound: Couldn't find KTEnvironment with ID=2
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation/finder_methods.rb:304:in `find_one'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation/finder_methods.rb:289:in `find_with_ids'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation/finder_methods.rb:107:in `find'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/base.rb:444:in `__send__'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/base.rb:444:in `find'
/usr/share/katello/app/models/user.rb:438:in `default_environment'
/usr/share/katello/app/models/user.rb:508:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:54:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:53:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:209:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:209:in `map'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:209:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/relation.rb:80:in `as_json'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:46:in `encode'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:77:in `check_for_circular_references'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:45:in `encode'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/json/encoding.rb:30:in `encode'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/core_ext/object/to_json.rb:15:in `to_json'
/usr/share/katello/app/controllers/api/users_controller.rb:51:in `index'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:150:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/rendering.rb:11:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/abstract_controller/callbacks.rb:18:in `process_action'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:462:in `_run__1161174178__process_action__199225275__callbacks'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:221:in `_conditional_callback_around_2770'
/usr/share/katello/lib/util/threadsession.rb:79:in `thread_locals'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:220:in `_conditional_callback_around_2770'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:446:in `_run__1161174178__process_action__199225275__callbacks'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:410:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:94:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:94:in `run_callbacks'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/abstract_controller/callbacks.rb:17:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/rescue.rb:17:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `instrument'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:119:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:41:in `process'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal.rb:138:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_controller/metal.rb:178:in `action'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:62:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:27:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-mount-0.7.1/lib/rack/mount/route_set.rb:150:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-mount-0.7.1/lib/rack/mount/code_generation.rb:93:in `recognize'
/usr/lib/ruby/gems/1.8/gems/rack-mount-0.7.1/lib/rack/mount/code_generation.rb:117:in `optimized_each'
/usr/lib/ruby/gems/1.8/gems/rack-mount-0.7.1/lib/rack/mount/code_generation.rb:92:in `recognize'
/usr/lib/ruby/gems/1.8/gems/rack-mount-0.7.1/lib/rack/mount/route_set.rb:141:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/routing/route_set.rb:493:in `call'
/usr/lib/ruby/gems/1.8/gems/warden-1.0.5/lib/warden/manager.rb:35:in `call'
/usr/lib/ruby/gems/1.8/gems/warden-1.0.5/lib/warden/manager.rb:34:in `catch'
/usr/lib/ruby/gems/1.8/gems/warden-1.0.5/lib/warden/manager.rb:34:in `call'
/usr/lib/ruby/gems/1.8/gems/sass-3.1.4/lib/sass/../sass/plugin/rack.rb:54:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/head.rb:14:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/methodoverride.rb:24:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/flash.rb:182:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/cookies.rb:302:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/query_cache.rb:32:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/query_cache.rb:12:in `cache'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/query_cache.rb:31:in `call'
/usr/lib/ruby/gems/1.8/gems/activerecord-3.0.10/lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/callbacks.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.10/lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/callbacks.rb:44:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/sendfile.rb:102:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
/usr/lib/ruby/gems/1.8/gems/actionpack-3.0.10/lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.10/lib/rails/rack/logger.rb:13:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/runtime.rb:17:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/lock.rb:34:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.10/lib/rails/application.rb:168:in `call'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.10/lib/rails/application.rb:77:in `send'
/usr/lib/ruby/gems/1.8/gems/railties-3.0.10/lib/rails/application.rb:77:in `method_missing'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/urlmap.rb:52:in `call'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/urlmap.rb:46:in `each'
/usr/lib/ruby/gems/1.8/gems/rack-1.3.0/lib/rack/urlmap.rb:46:in `call'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:84:in `pre_process'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:57:in `process'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/controllers/controller.rb:86:in `start'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:185:in `send'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:185:in `run_command'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:151:in `run!'
/usr/lib/ruby/gems/1.8/gems/thin-1.2.11/bin/thin:6
/usr/share/katello/script/thin:24:in `load'
/usr/share/katello/script/thin:24


Expected results:
One of two things:

1. Navigation to the environments tab should succeed and the users defaults should be None allowing for the user's default org and environment to be updated.

or

2. _IF_ an environment has been assigned as the default environment to any number of users any attempt to delete that environment should fail with a warning, "You tried to delete and environment where users are defined."

Additional info:
Comment 1 Eric Sammons 2012-07-17 14:00:32 EDT
attempt to work-a-round this issue failed.


sam> user update --username admin --no_default_environment
Couldn't find KTEnvironment with ID=2
Comment 2 Jordan OMara 2012-08-07 14:58:07 EDT
https://github.com/Katello/katello/pull/433

now, when you delete an environment, if a user has it set to his default it becomes unset. the next time he logs in, he is notified of htis
Comment 3 Tazim Kolhar 2012-10-10 05:48:20 EDT
Created attachment 624724 [details]
Default Organisation removed

VERIFIED :

#rpm -qa | grep katello
katello-configure-1.1.11-1h.el6_3.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-certs-tools-1.1.8-1h.el6_3.noarch
katello-glue-candlepin-1.1.14-2h.el6_3.noarch
katello-cli-common-1.1.10-1h.el6_3.noarch
katello-selinux-1.1.2-1h.el6_3.noarch
katello-cli-headpin-0.2.2-1.el6_2.noarch
katello-headpin-1.1.14-2h.el6_3.noarch
katello-common-1.1.14-2h.el6_3.noarch
katello-headpin-all-1.1.14-2h.el6_3.noarch
Comment 5 errata-xmlrpc 2013-02-21 14:16:50 EST
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.

http://rhn.redhat.com/errata/RHSA-2013-0544.html

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