Bug 840970 - Delete environment with members causes Couldn't find KTEnvironment with
Delete environment with members causes Couldn't find KTEnvironment with
Status: CLOSED UPSTREAM
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Content Management (Show other bugs)
6.0.1
Unspecified Unspecified
high Severity high (vote)
: Unspecified
: --
Assigned To: Jordan OMara
Katello QA List
: Triaged
: 858365 (view as bug list)
Depends On: 840969 858365
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-17 13:59 EDT by Eric Sammons
Modified: 2014-11-09 17:56 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 840969
Environment:
Last Closed: 2013-09-19 14:15:06 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)

  None (edit)
Description Eric Sammons 2012-07-17 13:59:53 EDT
+++ This bug was initially created as a clone of Bug #840969 +++

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 Tom McKay 2012-07-17 14:12:03 EDT
I'd vote for #1: If the environment no longer exists when the user attempts to access it, set it to None.

A separate RFE might be appropriate for a story like:
As an admin, I'd like to see a list of users for each environment.
Comment 2 Jordan OMara 2012-08-07 15:28:01 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 Jordan OMara 2012-09-18 15:11:34 EDT
*** Bug 858365 has been marked as a duplicate of this bug. ***
Comment 4 Mike McCune 2013-08-16 14:16:31 EDT
getting rid of 6.0.0 version since that doesn't exist
Comment 5 Mike McCune 2013-09-19 14:15:06 EDT
These bugs have been resolved in upstream projects for a period of months so I'm mass-closing them as CLOSED:UPSTREAM.  If this is a mistake feel free to re-open.

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