Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1207972 - on deleting a capsule: Operation FAILED: ERROR: update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts"
on deleting a capsule: Operation FAILED: ERROR: update or delete on table "...
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Users & Roles (Show other bugs)
6.1.0
Unspecified Unspecified
unspecified Severity high (vote)
: 6.1.4
: Unused
Assigned To: orabin
Sachin Ghai
http://projects.theforeman.org/issues...
: ReleaseNotes, Triaged
: 1160526 (view as bug list)
Depends On:
Blocks: sat61-release-notes
  Show dependency treegraph
 
Reported: 2015-04-01 02:49 EDT by Sachin Ghai
Modified: 2017-02-23 15:12 EST (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-11-19 10:56:08 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)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2474 normal SHIPPED_LIVE Satellite 6.1.4 bug fix update 2015-11-19 15:45:48 EST

  None (edit)
Description Sachin Ghai 2015-04-01 02:49:39 EDT
Description of problem:

On deleting capsule from webUI, following error raised:

--
Operation FAILED: ERROR:  update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts
--


production.log:
================

2015-04-01 12:14:37 [I] Processing by SmartProxiesController#index as HTML
2015-04-01 12:14:37 [I]   Rendered smart_proxies/index.html.erb within layouts/application (25.1ms)
2015-04-01 12:14:37 [I]   Rendered common/_searchbar.html.erb (3.7ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (3.2ms)
2015-04-01 12:14:37 [I]   Rendered home/_user_dropdown.html.erb (4.3ms)
2015-04-01 12:14:37 [I] Read fragment views/tabs_and_title_records-3 (0.1ms)
2015-04-01 12:14:37 [I]   Rendered home/_organization_dropdown.html.erb (4.6ms)
2015-04-01 12:14:37 [I]   Rendered home/_location_dropdown.html.erb (4.0ms)
2015-04-01 12:14:37 [I]   Rendered home/_org_switcher.html.erb (9.2ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (3.9ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (4.6ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (2.2ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (4.8ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (3.5ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (3.0ms)
2015-04-01 12:14:37 [I]   Rendered home/_submenu.html.erb (4.3ms)
2015-04-01 12:14:37 [I] Write fragment views/tabs_and_title_records-3 (0.9ms)
2015-04-01 12:14:37 [I]   Rendered home/_topbar.html.erb (49.6ms)
2015-04-01 12:14:37 [I]   Rendered layouts/base.html.erb (51.3ms)
2015-04-01 12:14:37 [I] Completed 200 OK in 112ms (Views: 79.8ms | ActiveRecord: 7.2ms)
2015-04-01 12:14:43 [I] Processing by SmartProxiesController#destroy as HTML
2015-04-01 12:14:43 [I]   Parameters: {"authenticity_token"=>"TjhkdNY1w4fqkuiURUn+FDFi9IcuBdx8s4bL8cUrI+o=", "id"=>"2-dhcp207-72-lab-eng-pnq-redhat-com"}
2015-04-01 12:14:43 [W] Operation FAILED: ERROR:  update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts"
DETAIL:  Key (id)=(2) is still referenced from table "hosts".

2015-04-01 12:14:43 [I]   Rendered common/500.html.erb within layouts/application (5.6ms)
2015-04-01 12:14:43 [I]   Rendered layouts/base.html.erb (1.4ms)
2015-04-01 12:14:43 [I] Completed 500 Internal Server Error in 79ms (Views: 9.5ms | ActiveRecord: 13.2ms)

Version-Release number of selected component (if applicable):
sat6.1 beta snap8 
(Satellite-6.1.0-RHEL-7-20150324.0)

How reproducible:
always

Steps to Reproduce:
1.
2.
3.

Actual results:
Operation FAILED: ERROR:  update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts"
DETAIL:  Key (id)=(2) is still referenced from table "hosts".

Expected results:
capsule should be removed. 
Additional info:
Comment 1 Sachin Ghai 2015-04-01 02:52:43 EDT
First, I removed the hostgroup and provisioned hosts binded with the capsule and then removed the capsule itself. Hostgroup and hosts provisioned via capsule, successfully removed. But on removing capsule, I got this error:

----
2015-04-01 11:55:06 [E] You may not destroy dhcp207-72.lab.eng.pnq.redhat.com as it is in use!
2015-04-01 11:55:06 [I] Failed to save: dhcp207-72.lab.eng.pnq.redhat.com is used by capsuleboothost.lab.eng.pnq.redhat.com, dhcp207-72.lab.eng.pnq.redhat.com is used by capsule_group
2015-04-01 11:55:06 [I] Redirected to https://dhcp201-113.englab.pnq.redhat.com/smart_proxies
2015-04-01 11:55:06 [I] Completed 302 Found in 280ms (ActiveRecord: 183.3ms)

----


production.log on destroying associated host and hostgroup:
===========================================================


Host destroy:
===============

[I] Processing by HostsController#destroy as HTML
2015-04-01 11:55:46 [I]   Parameters: {"authenticity_token"=>"TjhkdNY1w4fqkuiURUn+FDFi9IcuBdx8s4bL8cUrI+o=", "id"=>"capsuleboothost.lab.eng.pnq.redhat.com"}
2015-04-01 11:55:47 [I] Delete the DNS PTR record for 192.168.110.2/capsuleboothost.lab.eng.pnq.redhat.com
2015-04-01 11:55:48 [I] Delete the DNS A record for capsuleboothost.lab.eng.pnq.redhat.com/192.168.110.2
2015-04-01 11:55:48 [I] Delete DHCP reservation for capsuleboothost.lab.eng.pnq.redhat.com-52:54:00:e4:7a:b8/192.168.110.2
2015-04-01 11:55:48 [I] Delete the TFTP configuration for capsuleboothost.lab.eng.pnq.redhat.com
2015-04-01 11:55:48 [I] Remove puppet certificate for capsuleboothost.lab.eng.pnq.redhat.com
2015-04-01 11:55:52 [I] Delete the autosign entry for capsuleboothost.lab.eng.pnq.redhat.com
2015-04-01 11:55:52 [I] Redirected to https://dhcp201-113.englab.pnq.redhat.com/hosts
2015-04-01 11:55:52 [I] Completed 302 Found in 5665ms (ActiveRecord: 39.6ms)
2015-04-01 11:55:52 [I] Processing by HostsController#index as HTML
2015-04-01 11:55:52 [I]   Rendered hosts/_list.html.erb (64.2ms)
2015-04-01 11:55:52 [I]   Rendered hosts/index.html.erb within layouts/application (270.1ms)
2015-04-01 11:55:52 [I]   Rendered common/_searchbar.html.erb (6.8ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (3.3ms)
2015-04-01 11:55:52 [I]   Rendered home/_user_dropdown.html.erb (4.9ms)
2015-04-01 11:55:52 [I] Read fragment views/tabs_and_title_records-3 (0.1ms)
2015-04-01 11:55:52 [I]   Rendered home/_organization_dropdown.html.erb (5.3ms)
2015-04-01 11:55:52 [I]   Rendered home/_location_dropdown.html.erb (6.1ms)
2015-04-01 11:55:52 [I]   Rendered home/_org_switcher.html.erb (12.3ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (5.6ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (6.5ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (3.2ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (6.5ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (4.9ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (4.2ms)
2015-04-01 11:55:52 [I]   Rendered home/_submenu.html.erb (6.3ms)
2015-04-01 11:55:52 [I] Write fragment views/tabs_and_title_records-3 (1.4ms)
2015-04-01 11:55:52 [I]   Rendered home/_topbar.html.erb (67.7ms)
2015-04-01 11:55:52 [I]   Rendered layouts/base.html.erb (69.5ms)
2015-04-01 11:55:52 [I] Completed 200 OK in 391ms (Views: 345.8ms | ActiveRecord: 10.8ms)





hostgroup destroy:
=================

[I] Processing by HostgroupsController#destroy as HTML
2015-04-01 11:56:19 [I]   Parameters: {"authenticity_token"=>"TjhkdNY1w4fqkuiURUn+FDFi9IcuBdx8s4bL8cUrI+o=", "id"=>"2-capsule_group"}
2015-04-01 11:56:19 [I] Redirected to https://dhcp201-113.englab.pnq.redhat.com/hostgroups
2015-04-01 11:56:19 [I] Completed 302 Found in 150ms (ActiveRecord: 56.7ms)
2015-04-01 11:56:19 [I] Processing by HostgroupsController#index as HTML
2015-04-01 11:56:19 [I]   Rendered hostgroups/index.html.erb within layouts/application (258.3ms)
2015-04-01 11:56:19 [I]   Rendered common/_searchbar.html.erb (6.2ms)
2015-04-01 11:56:19 [I]   Rendered home/_submenu.html.erb (4.7ms)
2015-04-01 11:56:19 [I]   Rendered home/_user_dropdown.html.erb (2.7ms)
2015-04-01 11:56:19 [I] Read fragment views/tabs_and_title_records-3 (0.2ms)
2015-04-01 11:56:19 [I]   Rendered home/_topbar.html.erb (9.9ms)
2015-04-01 11:56:19 [I]   Rendered layouts/base.html.erb (12.4ms)
2015-04-01 11:56:19 [I] Completed 200 OK in 304ms (Views: 278.0ms | ActiveRecord: 6.4ms)
Comment 3 Corey Welton 2015-04-01 11:31:58 EDT
I'd seen this but hadn't written it up yet.  I had also found a workaround for this, but I forget what it entails, entirely.At a minimum, however, you need to remove the content host before removing capsule.

That said, FK constraint error is nasty.
Comment 5 Mike McCune 2015-04-09 11:13:14 EDT
*** Bug 1160526 has been marked as a duplicate of this bug. ***
Comment 6 Tom Caspy 2015-04-20 05:42:59 EDT
I was unable to reproduce, can you provide a test system which I can connect to so I can see what's happening there?
Comment 7 Ohad Levy 2015-05-07 10:08:27 EDT
qe bump?
Comment 9 Bryan Kearney 2015-05-15 17:33:21 EDT
Any luck reproducing this?
Comment 10 Sachin Ghai 2015-05-18 06:58:15 EDT
Ok, Now I've setup with latest compose (sat6.1 GA snap4 compose2) where this bz is reproducible.



2015-05-18 15:41:36 [I] Processing by SmartProxiesController#destroy as HTML
2015-05-18 15:41:36 [I]   Parameters: {"authenticity_token"=>"ivOy5aPVZNBJtIXJwBu8ZC3uM29FbWw9ZssGn5jX5EI=", "id"=>"4-dhcp207-209-lab-eng-pnq-redhat-com"}
2015-05-18 15:41:36 [W] Operation FAILED: ERROR:  update or delete on table "smart_proxies" violates foreign key constraint "hosts_puppet_ca_proxy_id_fk" on table "hosts"
DETAIL:  Key (id)=(4) is still referenced from table "hosts".

2015-05-18 15:41:36 [I]   Rendered common/500.html.erb within layouts/application (6.0ms)
2015-05-18 15:41:36 [I]   Rendered layouts/base.html.erb (1.4ms)
2015-05-18 15:41:36 [I] Completed 500 Internal Server Error in 96ms (Views: 10.3ms | ActiveRecord: 14.8ms)


I'll share the setup with @tcaspy@redhat.com. thanks


Reproducible steps:
=================

1. Register a capsule with sat61 server and sync contents to capsule.
2. Configure provisioning on capsule and create hostgroup and provision host on libvirt compute-resource
3. now to remove capsule
a) remove all hosts provisioned via capsule
b) unassociate capsule from subnet
c) unassociate capsule from hostgroup
d) unregister capsule
e) delete capsule.
Comment 12 orabin 2015-07-22 05:14:51 EDT
Created redmine issue http://projects.theforeman.org/issues/11188 from this bug
Comment 13 Bryan Kearney 2015-07-22 06:03:55 EDT
Upstream bug assigned to orabin@redhat.com
Comment 14 Bryan Kearney 2015-07-22 06:03:56 EDT
Upstream bug assigned to orabin@redhat.com
Comment 15 Bryan Kearney 2015-08-25 14:34:47 EDT
Upstream bug component is Provisioning
Comment 18 Bryan Kearney 2015-09-16 08:04:32 EDT
Upstream bug component is Users & Roles
Comment 19 Bryan Kearney 2015-09-16 08:04:34 EDT
Moving to POST since upstream bug http://projects.theforeman.org/issues/11188 has been closed
-------------
Ori Rabin
Applied in changeset commit:08d4fc31447487181f59e7be54121fc681f3a5b4.
Comment 22 Mike McCune 2015-10-05 17:19:36 EDT
Code from this bug is causing an error while viewing Organizations and Locations in the UI:


Foreman::Exception
ERF42-5434 [Foreman::Exception]: unknown permission view_config_templates
app/services/association_authorizer.rb:21:in `view_permission_name'
app/services/association_authorizer.rb:9:in `authorized_associations'
app/helpers/layout_helper.rb:88:in `multiple_selects'
app/views/taxonomies/_form.html.erb:144:in `block in _app_views_taxonomies__form_html_erb___1433964276212543786_140179700'
app/helpers/layout_helper.rb:307:in `form_for'
app/views/taxonomies/_form.html.erb:3:in `_app_views_taxonomies__form_html_erb___1433964276212543786_140179700'
app/views/taxonomies/edit.html.erb:4:in `_app_views_taxonomies_edit_html_erb___3375171378674763924_123649080'
app/controllers/concerns/foreman/controller/taxonomies_controller.rb:67:in `block in edit'
app/models/taxonomy.rb:58:in `block in no_taxonomy_scope'
app/models/taxonomy.rb:65:in `block (2 levels) in as_taxonomy'
app/models/concerns/foreman/thread_session.rb:148:in `as_location'
app/models/taxonomy.rb:64:in `block in as_taxonomy'
app/models/concerns/foreman/thread_session.rb:113:in `as_org'
app/models/taxonomy.rb:63:in `as_taxonomy'
app/models/taxonomy.rb:57:in `no_taxonomy_scope'
app/controllers/concerns/foreman/controller/taxonomies_controller.rb:65:in `edit'
app/models/concerns/foreman/thread_session.rb:33:in `clear_thread'
lib/middleware/catch_json_parse_errors.rb:9:in `call'

I'm going to roll back the above mentioned cherry-pick and move this one to 6.1.4
Comment 30 Sachin Ghai 2015-11-06 02:33:56 EST
Verified with sat6.1.4 compose3. Now capsule can be deleted successfully.

here are the logs from production.log on successfully deleting it:

2015-11-06 02:32:06 [I] Processing by SmartProxiesController#destroy as HTML
2015-11-06 02:32:06 [I]   Parameters: {"authenticity_token"=>"l13ZNyZ1NXaTDVIZM0IwcRw1pcczaLrTS7axnadvehQ=", "id"=>"2-cloud-qe-4-idmqe-lab-eng-bos-redhat-com"}
2015-11-06 02:32:06 [I] Redirected to https://cloud-qe-15.idmqe.lab.eng.bos.redhat.com/smart_proxies
2015-11-06 02:32:06 [I] Completed 302 Found in 51ms (ActiveRecord: 27.2ms)
2015-11-06 02:32:07 [I] Processing by SmartProxiesController#index as HTML
2015-11-06 02:32:07 [I]   Rendered smart_proxies/index.html.erb within layouts/application (7.4ms)
2015-11-06 02:32:07 [I]   Rendered common/_searchbar.html.erb (2.2ms)
2015-11-06 02:32:07 [I]   Rendered home/_submenu.html.erb (1.5ms)
2015-11-06 02:32:07 [I]   Rendered home/_user_dropdown.html.erb (1.0ms)
2015-11-06 02:32:07 [I] Read fragment views/tabs_and_title_records-3 (0.1ms)
2015-11-06 02:32:07 [I]   Rendered home/_topbar.html.erb (3.4ms)
2015-11-06 02:32:07 [I]   Rendered layouts/base.html.erb (131.4ms)
2015-11-06 02:32:07 [I] Completed 200 OK in 152ms (Views: 142.0ms | ActiveRecord: 2.2ms)
Comment 33 errata-xmlrpc 2015-11-19 10:56:08 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.

https://access.redhat.com/errata/RHBA-2015:2474

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