Bug 1589736

Summary: Can not delete organization, if virt-who is configured
Product: Red Hat Satellite Reporter: Anand Agrawal <aagrawal>
Component: Virt-who Configure PluginAssignee: Amit Upadhye <aupadhye>
Status: CLOSED ERRATA QA Contact: Perry Gagne <pgagne>
Severity: high Docs Contact: satellite-doc-list
Priority: unspecified    
Version: 6.3.1CC: aupadhye, mhulan, pcreech
Target Milestone: 6.5.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: rubygem-foreman_virt_who_configure 0.3.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-14 12:37:23 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: 1645144    
Bug Blocks:    

Description Anand Agrawal 2018-06-11 09:52:07 UTC
Description of problem:

If `Virt-who Configurations` is created on Satellite. It is not possible to delete the organization.

It throws, foreign key dependencies error as below:

PG::Error: ERROR:  update or delete on table "taxonomies" violates foreign key constraint "fk_rails_972e5a3807" on table "foreman_virt_who_configure_configs"
DETAIL:  Key (id)=(13) is still referenced from table "foreman_virt_who_configure_configs".
: DELETE FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') AND "taxonomies"."id" = $1

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

How reproducible:
Always

Steps to Reproduce:
1. Create any Organization. example: 'Test Org'
2. Switch to the 'Test Org'
3. GoTo Infrastructure -> Virt-who Configurations -> Create config
4. Insert mandatory field and submit.
5. Now switch to other organization to delte 'Test Org'
6. Delete the organization. Check the task, task will be in error state with the PG:ERROR

Actual results:
PG::Error: ERROR:  update or delete on table "taxonomies" violates foreign key constraint "fk_rails_972e5a3807" on table "foreman_virt_who_configure_configs"
DETAIL:  Key (id)=(13) is still referenced from table "foreman_virt_who_configure_configs".
: DELETE FROM "taxonomies" WHERE "taxonomies"."type" IN ('Organization') AND "taxonomies"."id" = $1

Expected results:

Organization should be deleted without error.

Additional info:

Comment 1 Marek Hulan 2018-06-11 10:57:27 UTC
A valid bug, but the workaround should be trivial, delete all configurations for that organization first. Note that this would also destroy the service user that virt-who uses for authentication, so it basically make virt-who instance configuration invalid. But if you're deleting the organization, I guess that's not a problem and is kind of expected.

Comment 2 Marek Hulan 2018-06-11 10:58:03 UTC
Created redmine issue http://projects.theforeman.org/issues/23878 from this bug

Comment 5 Marek Hulan 2018-06-11 12:12:05 UTC
Interesting, could you grab a production.log from a moment when user clicks the delete button? The traceback from there might be useful.

Comment 8 Perry Gagne 2019-01-24 18:59:13 UTC
Verified fix in 6.5 snap 12

Created org "VDCOrg"
Created/Deployed virt-who config
waited for hypervisor reports, etc to come in. 
Deleted VDCOrg

VDCOrg was deleted successfully.

Comment 10 errata-xmlrpc 2019-05-14 12:37:23 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/RHSA-2019:1222