Bug 1242132

Summary: update or delete on table "taxonomies" violates foreign key constraint "hosts_organization_id_fk" on table "hosts"
Product: Red Hat Satellite Reporter: Mahesh Taru <mtaru>
Component: Discovery PluginAssignee: Marek Hulan <mhulan>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: high Docs Contact:
Priority: high    
Version: 6.0.8CC: bbuckingham, cwelton, lzap, mhulan, ohadlevy, sghai
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
URL: http://projects.theforeman.org/issues/14294
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:14:24 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:

Description Mahesh Taru 2015-07-11 09:14:56 UTC
Description of problem:
Yum update done on Satellite 6.0.5 version. After that Default_Organization and Default_Location got recreated.
Unable to delete using hammer command.
After yum update the upgrade steps from solution section of https://access.redhat.com/errata/RHBA-2015:0054 were not performed.

After perform steps from solution section of https://access.redhat.com/errata/RHBA-2015:0054 'foreman-rake katello:reindex' results in below error.
***********
# foreman-rake katello:reindex
Elasticsearch Indices cleared.
Re-indexing User
Re-indexing Organization
rake aborted!
Katello::Resources::Candlepin::CandlepinResource: 404 Resource Not Found
{"displayMessage":"Organization with id Default_Organization could not be
found.","requestUuid":"d1bf7434-a779-4565-91db-289d8b97672b"} (GET
/candlepin/owners/Default_Organization/servicelevels)
************

Version-Release number of selected component (if applicable):
satellite 6.0.8

How reproducible:


Steps to Reproduce:
1. Yum update on satellite 6.0.5
2. Perform steps from solution section of https://access.redhat.com/errata/RHBA-2015:0054
3. Try to delete organization or location using hammer command.

Actual results:
rake aborted!
Katello::Resources::Candlepin::CandlepinResource: 404 Resource Not Found
{"displayMessage":"Organization with id Default_Organization could not be
found.","requestUuid":"d1bf7434-a779-4565-91db-289d8b97672b"} (GET
/candlepin/owners/Default_Organization/servicelevels)


Expected results:
The reindexing from upgrade steps should result successful.
Using hammer should be able to delete unwanted organization & location.

Additional info:
- katello-service working fine
- permissions & ownership of /etc/pki/katello & its contents are correct
- product list is shows blank after upgrade steps

- # foreman-rake katello:reindex --trace
** Invoke katello:reindex (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke katello:reset_backends:elasticsearch (first_time)
** Invoke environment
** Execute katello:reset_backends:elasticsearch
Elasticsearch Indices cleared.
** Execute katello:reindex
Re-indexing User
Re-indexing Organization
rake aborted!
Katello::Resources::Candlepin::CandlepinResource: 404 Resource Not Found
{"displayMessage":"Organization with id Default_Organization could not be
found.","requestUuid":"b99e44cc-dc6c-412e-89b6-3870f4da482c"} (GET
/candlepin/owners/Default_Organization/servicelevels)
/opt/rh/ruby193/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/a
bstract_response.rb:48:in `return!'
/opt/rh/ruby193/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/r
equest.rb:230:in `process_result'
/opt/rh/ruby193/root/usr/share/gems/gems/rbovirt-0.0.29/lib/restclient_ext/
request.rb:50:in `block in transmit'
/opt/rh/ruby193/root/usr/share/ruby/net/http.rb:746:in `start'
/opt/rh/ruby193/root/usr/share/gems/gems/rbovirt-0.0.29/lib/restclient_ext/
request.rb:44:in `transmit'
/opt/rh/ruby193/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/r
equest.rb:64:in `execute'
/opt/rh/ruby193/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/r
equest.rb:33:in `execute'
/opt/rh/ruby193/root/usr/share/gems/gems/rest-client-1.6.7/lib/restclient/r
esource.rb:51:in `get'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/http
_resource.rb:97:in `get'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/reso
urces/candlepin.rb:464:in `service_levels'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/models/katello/g
lue/candlepin/owner.rb:26:in `block (2 levels) in included'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/lazy
_accessor.rb:176:in `instance_eval'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/lazy
_accessor.rb:176:in `run_initializer'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/lazy
_accessor.rb:155:in `lazy_attribute_get'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/lib/katello/lazy
_accessor.rb:75:in `block (2 levels) in lazy_accessor'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/app/models/katello/g
lue/candlepin/owner.rb:35:in `serializable_hash'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/model/search.r
b:290:in `to_hash'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/index.rb:195:i
n `block in bulk'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/index.rb:176:i
n `map'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/index.rb:176:i
n `bulk'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/index.rb:273:i
n `bulk_store'
/opt/rh/ruby193/root/usr/share/gems/gems/tire-0.6.2/lib/tire/index.rb:300:i
n `import'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/lib/katello/tasks/re
index.rake:19:in `block (3 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/lib/katello/tasks/re
index.rake:7:in `each'
/opt/rh/ruby193/root/usr/share/gems/gems/katello-1.5.0/lib/katello/tasks/re
index.rake:7:in `block (2 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `block in execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in `block in
invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in
`invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in `invoke'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in
`invoke_task'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2
levels) in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in
top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
`standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in
run'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in
`standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
/opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
Tasks: TOP => katello:reindex

Comment 1 RHEL Program Management 2015-07-11 09:24:15 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 David O'Brien 2015-08-20 01:01:37 UTC
Can I get some suitable doc text to add to a rel note for this?

thanks

Comment 8 Bryan Kearney 2016-03-21 16:12:11 UTC
Upstream bug component is Discovery Plugin

Comment 10 Bryan Kearney 2016-03-22 10:12:02 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14294 has been closed
-------------
Marek Hulán
Applied in changeset commit:foreman_discovery|6feb649b997ea3669b67051cf5ae18e6d1b5b821.

Comment 11 David O'Brien 2016-04-18 00:48:43 UTC
Reset docs contact <> daobrien

Comment 12 Sachin Ghai 2016-05-12 11:58:17 UTC
@mhulan: Hey.. Could you please help to provide verification steps. As per comment6, I guess, user should get proper error when he tries to delete org/location and when a discovered host is already associated to same org/location. Please confirm. Thanks

Comment 13 Marek Hulan 2016-05-12 12:02:54 UTC
Exactly, create a discovered host in org/loc, then try to delete that org/loc, it should display error message instead of 500.

Comment 14 Sachin Ghai 2016-05-30 11:49:39 UTC
Thanks Marek. To verify this ba with sat62 GA snap13.1

I discovered a host with an org/location named mordo. Later, I tried to delete same location and got following error:

]# hammer -u admin -p changeme location delete --name mordo
Could not delete the location:
  mordo is used by mac5254008e4530


On deleting the location from webUI:

2016-05-30 07:46:50 [app] [I] Processing by LocationsController#destroy as HTML
2016-05-30 07:46:50 [app] [I]   Parameters: {"authenticity_token"=>"39f8c1o1kqJWvubXrv5F5W0T0xybyRSJr993F399Eak=", "id"=>"4-mordo"}
2016-05-30 07:46:50 [app] [E] You may not destroy mordo as it is in use!
2016-05-30 07:46:50 [app] [I] Failed to save: mordo is being used by a hidden Host::Discovered resource
2016-05-30 07:46:50 [app] [I] Redirected to https://cloud-qe-3.idmqe.lab.eng.bos.redhat.com/locations

Comment 15 Sachin Ghai 2016-05-30 11:50:31 UTC
Moving this to verified.

Comment 16 Bryan Kearney 2016-07-27 11:14:24 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/RHBA-2016:1501