Bug 1013837

Summary: Unable to delete an user if the user had any active notifications
Product: Red Hat Satellite Reporter: sthirugn <sthirugn>
Component: Content ManagementAssignee: Petr Chalupa <pchalupa>
Status: CLOSED CURRENTRELEASE QA Contact: Tazim Kolhar <tkolhar>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.0.2CC: cwelton, hhovsepy, jmontleo, mmccune, tkolhar, tsanders
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1013798 Environment:
Last Closed: 2014-07-02 14:05:18 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: 1013798, 1026936, 1026948    

Description sthirugn@redhat.com 2013-09-30 21:45:50 UTC
+++ This bug was initially created as a clone of Bug #1013798 +++

Description of problem:
Unable to delete an user if the user had any active notifications

Version-Release number of selected component (if applicable):
* candlepin-0.8.26-1.el6sam.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.26-1.el6sam.noarch
* candlepin-tomcat6-0.8.26-1.el6sam.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.3-11.el6sat.noarch
* katello-cli-common-1.4.3-11.el6sat.noarch
* katello-common-1.4.3-18.el6sam_splice.noarch
* katello-configure-1.4.4-5.el6sam.noarch
* katello-glue-candlepin-1.4.3-18.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-18.el6sam_splice.noarch
* katello-headpin-1.4.3-18.el6sam_splice.noarch
* katello-headpin-all-1.4.3-18.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.34-1.el6sam.noarch
* thumbslug-selinux-0.0.34-1.el6sam.noarch


How reproducible:
Always

Steps to Reproduce:
1. Navigate to SAM 1.3.1
2. Create an user - User1
3. Log in as User1
4. Do any of the user actions for User1 which will create notification: 
Upload manifest (or) Create an ORG (or) Create Activation Key (or) something else
5. Log out and log in back as an other admin user
6. Attempt to remove the User1

Actual results:
UI error thrown (screenshot attached)

Expected results:
No errors thrown

Additional info:

--- Additional comment from  on 2013-09-30 15:38:14 EDT ---



--- Additional comment from  on 2013-09-30 15:40:50 EDT ---



--- Additional comment from  on 2013-09-30 17:00:16 EDT ---

WORKAROUND is to remove all the user roles associated with the user.

--- Additional comment from  on 2013-09-30 17:07:20 EDT ---

Ignore my Comment 3 above.  The user name is not displayed in UI anymore, but using this username, I can still access the SAM UI.

--- Additional comment from  on 2013-09-30 17:09:36 EDT ---

So the only WORKAROUND will be to go the Roles and remove the user manually from each associated role.

Comment 2 Mike McCune 2013-10-03 20:26:55 UTC
other tables that need to be cleaned out when deleting a user (query to find all user table FKs):

katello=> SELECT
    tc.constraint_name, tc.table_name, kcu.column_name, 
    ccu.table_name AS foreign_table_name,
    ccu.column_name AS foreign_column_name 
FROM 
    information_schema.table_constraints AS tc 
    JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name
    JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name
WHERE constraint_type = 'FOREIGN KEY' AND ccu.table_name = 'users' AND ccu.column_name = 'id';
        constraint_name         |     table_name      | column_name | foreign_table_name | foreign_column_name 
--------------------------------+---------------------+-------------+--------------------+---------------------
 activation_keys_user_id_fk     | activation_keys     | user_id     | users              | id
 changeset_users_user_id_fk     | changeset_users     | user_id     | users              | id
 help_tips_user_id_fk           | help_tips           | user_id     | users              | id
 roles_users_user_id_fk         | roles_users         | user_id     | users              | id
 search_favorites_user_id_fk    | search_favorites    | user_id     | users              | id
 search_histories_user_id_fk    | search_histories    | user_id     | users              | id
 task_statuses_user_id_fk       | task_statuses       | user_id     | users              | id
 user_notices_user_id_fk        | user_notices        | user_id     | users              | id
 organizations_users_user_id_fk | organizations_users | user_id     | users              | id
(9 rows)

Comment 3 Petr Chalupa 2013-10-11 14:42:10 UTC
fixed in 6a40eba9618409b004807484fdb0dcf1a6d9f60a

Comment 6 Hayk Hovsepyan 2013-10-21 08:24:38 UTC
Tested on revision:
Katello-Katello-Installation-RegisterRHNClassic-1.1-4.noarch
foreman-postgresql-1.3.0-18.el6sat.noarch
candlepin-scl-runtime-1-5.el6_4.noarch
apr-util-ldap-1.3.9-3.el6_0.1.x86_64
openldap-2.4.23-31.el6.x86_64
pulp-nodes-common-2.3.0-0.22.beta.el6sat.noarch
candlepin-scl-1-5.el6_4.noarch
elasticsearch-0.19.9-8.el6sat.noarch
katello-glue-candlepin-1.4.6-40.el6sat.noarch
candlepin-tomcat6-0.8.25-1.el6sam.noarch
katello-qpid-broker-key-pair-1.0-1.noarch
Katello-Katello-Configuration-KatelloClient-1.1-53.noarch
Katello-Katello-Installation-Satellite6Latest-1.0-13.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-qpid-client-key-pair-1.0-1.noarch
foreman-1.3.0-18.el6sat.noarch
katello-cli-common-1.4.3-24.el6sat.noarch
pulp-selinux-2.3.0-0.22.beta.el6sat.noarch
python-ldap-2.3.10-1.el6.x86_64
katello-certs-tools-1.4.4-1.el6sat.noarch
pulp-server-2.3.0-0.22.beta.el6sat.noarch
pulp-katello-plugins-0.2-1.el6sat.noarch
pulp-nodes-parent-2.3.0-0.22.beta.el6sat.noarch
candlepin-scl-quartz-2.1.5-5.el6_4.noarch
candlepin-selinux-0.8.25-1.el6sam.noarch
signo-katello-0.0.23-2.el6sat.noarch
katello-glue-pulp-1.4.6-40.el6sat.noarch
katello-selinux-1.4.4-4.el6sat.noarch
katello-1.4.6-40.el6sat.noarch
katello-configure-foreman-1.4.7-6.el6sat.noarch
katello-all-1.4.6-40.el6sat.noarch
ruby193-rubygem-ldap_fluff-0.2.2-2.el6sat.noarch
foreman-proxy-1.3.0-3.el6sat.noarch
pulp-rpm-handlers-2.3.0-0.22.beta.el6sat.noarch
katello-agent-1.4.4-3.el6sat.noarch
Katello-Katello-Installation-HammerCLI-1.0-9.noarch
katello-cli-1.4.3-24.el6sat.noarch
candlepin-scl-rhino-1.7R3-1.el6_4.noarch
katello-configure-1.4.7-6.el6sat.noarch
pulp-puppet-plugins-2.3.0-0.22.beta.el6sat.noarch
pulp-rpm-plugins-2.3.0-0.22.beta.el6sat.noarch
candlepin-0.8.25-1.el6sam.noarch
ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
katello-common-1.4.6-40.el6sat.noarch
katello-glue-elasticsearch-1.4.6-40.el6sat.noarch
katello-foreman-all-1.4.6-40.el6sat.noarch
candlepin-cert-consumer-hades.usersys.redhat.com-1.0-1.noarch
signo-0.0.23-2.el6sat.noarch
Katello-Katello-Sanity-ImportKeys-1.2-1.noarch


User delete still fails:
1. Create an user - User1
2. Log in as User1
3. Create org, import manifest, create activation key.
4. Log out and log in back as an other admin user
5. Attempt to remove the User1, it will fail with error:
"ERROR: update or delete on table "users" violates foreign key constraint "activation_keys_user_id_fk" on table "activation_keys" DETAIL: Key (id)=(3) is still referenced from table "activation_keys". (PGError) "

Comment 7 Petr Chalupa 2013-10-21 09:11:12 UTC
The original bug related to notifications is fixed, this is failing because of missing commit from bug https://bugzilla.redhat.com/show_bug.cgi?id=1007117. Please cherry-pick https://github.com/Katello/katello/commit/eb3248f774bca8a7ecfdc1241ea5952c6caaf768 to fix FK activation-key issue.

Comment 11 Hayk Hovsepyan 2013-10-24 13:45:20 UTC
Tested on revision:
Katello-Katello-Installation-RegisterRHNClassic-1.1-4.noarch
foreman-postgresql-1.3.0-20.el6sat.noarch
candlepin-scl-runtime-1-5.el6_4.noarch
python-ldap-2.3.10-1.el6.x86_64
apr-util-ldap-1.3.9-3.el6_0.1.x86_64
openldap-2.4.23-31.el6.x86_64
katello-certs-tools-1.4.4-1.el6sat.noarch
pulp-server-2.3.0-0.22.beta.el6sat.noarch
pulp-nodes-parent-2.3.0-0.22.beta.el6sat.noarch
katello-glue-pulp-1.4.6-47.el6sat.noarch
katello-1.4.6-47.el6sat.noarch
candlepin-selinux-0.8.25-1.el6sam.noarch
katello-qpid-broker-key-pair-1.0-1.noarch
Katello-Katello-Configuration-KatelloClient-1.1-53.noarch
Katello-Katello-Installation-Satellite6Latest-1.0-13.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-qpid-client-key-pair-1.0-1.noarch
foreman-1.3.0-20.el6sat.noarch
katello-cli-common-1.4.3-27.el6sat.noarch
pulp-selinux-2.3.0-0.22.beta.el6sat.noarch
katello-configure-1.4.7-7.el6sat.noarch
pulp-puppet-plugins-2.3.0-0.22.beta.el6sat.noarch
pulp-nodes-common-2.3.0-0.22.beta.el6sat.noarch
pulp-rpm-plugins-2.3.0-0.22.beta.el6sat.noarch
candlepin-scl-1-5.el6_4.noarch
elasticsearch-0.19.9-8.el6sat.noarch
katello-common-1.4.6-47.el6sat.noarch
katello-glue-candlepin-1.4.6-47.el6sat.noarch
katello-glue-elasticsearch-1.4.6-47.el6sat.noarch
candlepin-tomcat6-0.8.25-1.el6sam.noarch
katello-all-1.4.6-47.el6sat.noarch
ruby193-rubygem-ldap_fluff-0.2.2-2.el6sat.noarch
foreman-proxy-1.3.0-3.el6sat.noarch
pulp-rpm-handlers-2.3.0-0.22.beta.el6sat.noarch
katello-agent-1.4.4-3.el6sat.noarch
Katello-Katello-Installation-HammerCLI-1.0-9.noarch
signo-0.0.23-2.el6sat.noarch
katello-cli-1.4.3-27.el6sat.noarch
candlepin-scl-rhino-1.7R3-1.el6_4.noarch
pulp-katello-plugins-0.2-1.el6sat.noarch
candlepin-scl-quartz-2.1.5-5.el6_4.noarch
signo-katello-0.0.23-2.el6sat.noarch
ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
katello-selinux-1.4.4-4.el6sat.noarch
katello-configure-foreman-1.4.7-7.el6sat.noarch
candlepin-0.8.25-1.el6sam.noarch
katello-foreman-all-1.4.6-47.el6sat.noarch
candlepin-cert-consumer-hades.usersys.redhat.com-1.0-1.noarch
Katello-Katello-Sanity-ImportKeys-1.2-1.noarch

The same steps for reproduce, the same error is shown.

1. Create an user - User1
2. Log in as User1
3. Create org, import manifest, create activation key.
4. Log out and log in back as an other admin user
5. Attempt to remove the User1, it will fail with error:
"ERROR: update or delete on table "users" violates foreign key constraint "activation_keys_user_id_fk" on table "activation_keys" DETAIL: Key (id)=(3) is still referenced from table "activation_keys". (PGError) "

Comment 15 Mike McCune 2013-11-05 21:19:29 UTC
moving to test this in MDP3

Comment 16 Mike McCune 2013-11-05 21:20:23 UTC
*** Bug 1026936 has been marked as a duplicate of this bug. ***

Comment 17 Tazim Kolhar 2014-04-28 07:00:47 UTC
VERIFIED :
user deleted

Comment 18 Bryan Kearney 2014-07-02 14:05:18 UTC
This was delivered with 6.0.3, which is the Satellite 6 Beta.