Bug 1131611

Summary: After upgrading to 6.0.4 and 'katello-service restart' or upgrading the schema satellite removes foreman_admin, and foreman_api_admin are removed from satellite's database
Product: Red Hat Satellite Reporter: Aaron Thomas <aathomas>
Component: Users & RolesAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WORKSFORME QA Contact: Katello QA List <katello-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.4CC: mmccune, xdmoon
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-04 13:50:47 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:
Bug Depends On:    
Bug Blocks: 1115190    

Description Aaron Thomas 2014-08-19 16:29:12 UTC
Description of problem:
-----------------------------------------
After upgrading to the nightly build and 'katello-service restart' or upgrading the schema satellite removes the users foreman_admin, and foreman_api_admin from the database. 


Version-Release number of selected component (if applicable):
-----------------------------------------
- 6.0.4 (http://satellite6.lab.eng.rdu2.redhat.com/devel/candidate-trees/Satellite/latest-stable-Satellite-6.0-RHEL-6/compose/Satellite/x86_64/os/)



How reproducible:
-----------------------------------------
- Highly reproducible 



Steps to Reproduce:
-----------------------------------------
 1. Upgrade satellite 6 with yum
 2. # foreman-rake db:migrate or # katello-service restart
 3. # foreman-rake db:seed



After the users foreman_admin and foreman_api_admin are removed: /var/log/foreman/production.log
-----------------------------------------
Processing by UsersController#login as HTML
  Rendered users/login.html.erb within layouts/login (1.4ms)
  Rendered layouts/base.html.erb (0.7ms)
Completed 200 OK in 4ms (Views: 2.9ms | ActiveRecord: 0.0ms)
Processing by UsersController#login as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"48OkM9b8oKQtf6H3+BkDMSs2dNtKNaqmNp3gI33E7fQ=", "login"=>{"login"=>"admin", "password"=>"[FILTERED]"}, "commit"=>"Login"}
Operation FAILED: ERF42-7495 [Foreman::Exception]: Cannot find user foreman_admin when switching context
  Rendered common/500.html.erb within layouts/application (3.0ms)
  Rendered layouts/base.html.erb (0.9ms)


WebGUI message:
-----------------------------------------
Oops, we're sorry but something went wrong

Error

ERF42-7495 [Foreman::Exception]: Cannot find user foreman_admin when switching context
If you feel this is an error with Foreman itself, please open a new issue with Foreman ticketing system, You would probably need to attach the Full trace and relevant log entries.



Expected results:
-----------------------------------------
The users are not removed the database, satellite is upgraded, and is fully functional. 



Adding the users to satellite's database fixes the issues:
-----------------------------------------
# su - postgres 

# psql foreman

foreman=# insert into users (login, firstname, lastname, admin, created_at, updated_at) values ('foreman_admin', 'Anonymous', 'Admin', False, '2014-08-12 19:12:03.910693', '2014-08-12 19:12:03.910693');

foreman=# insert into users (login, firstname, lastname, admin, created_at, updated_at) values ('foreman_api_admin', 'API', 'Admin', False, '2014-08-12 19:12:03.910693', '2014-08-12 19:12:03.910693');

Comment 2 RHEL Program Management 2014-08-19 16:43:06 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 4 Aaron Thomas 2014-08-19 17:17:02 UTC
Marcelo IRC:mmello also hit the same bug and assisted with providing the fix, mmello++