+++ This bug was initially created as a clone of Bug #245860 +++ Description of problem: I created 3 users, went to that user and created a notification method under each user. I actually found out I didn't need a user so the user was deleted. The notifications still appear in the pulldown list after deleting the users. Went to an existing account, defined the same 3 notifications under his account. I now have duplicates and does not know how to remove these. I did this thru the satellite web monitor interface. The duplicate notifications do not appear under the "Notification" tab - but these duplicates can be seen while creating/editing ProbeSuite Go to: Monitoring -> Proble Suites -> Click on any of the Name (probe suit) -> Probe -> Create New Probe -> Tick "Probe Notifications" Now under the "Notification Method" you will be able to see those methods which were under the user which is already deleted. Example : You create a user test123 Under this user create a notification method "test notification" Now delete this user Still under the Create Probe in the pull down menu of "Notification Method" you will see the one's which should have been deleted. Thanks, Paresh
More from that Satellite bugzilla: Reproduced on 4.2 satellite. From the code (/usr/lib/perl5/site_perl/5.8.5/Sniglets/ContactMethod.pm), looks like a new ContactGroup is created with one member - the ContactMethod with the same name as the ContactGroup - everytime a new notification method is created. The problem is that deleting a ContactMethod for a particular user works as expected (i.e., removes both ContactMethod and ContactGroup from the DB), but deleting a user removes only the ContactMethod for the user and not the ContactGroup. Monitoring UI pulls up the ContactGroups, which is why it seems to still see the deleted notification method. E.g., add a user, add a notification method called method1, then delete this user, db shows the ContactMethod removed but ContactGroup still there - SQL> select method_name, contact_id from rhn_contact_methods; METHOD_NAME CONTACT_ID -------------------- ---------- Panic Destination 1 SQL> select recid, contact_group_name from rhn_contact_groups; RECID CONTACT_GROUP_NAME ---------- ------------------------------ 1 Panic Destination 2 method1 SQL> select contact_group_id, member_contact_method_id from rhn_contact_group_members; CONTACT_GROUP_ID MEMBER_CONTACT_METHOD_ID ---------------- ------------------------ 1 1 Now, create a notification method called testmethod for another user, db shows - SQL> select method_name, contact_id from rhn_contact_methods; METHOD_NAME CONTACT_ID -------------------- ---------- Panic Destination 1 testmethod 4 SQL> select recid, contact_group_name from rhn_contact_groups; RECID CONTACT_GROUP_NAME ---------- ------------------------------ 1 Panic Destination 2 method1 3 testmethod CONTACT_GROUP_ID MEMBER_CONTACT_METHOD_ID ---------------- ------------------------ 1 1 3 3 Now, instead of deleting this user, just delete the notification method, db (as well as the monitoring UI) shows this worked: SQL> select method_name, contact_id from rhn_contact_methods; METHOD_NAME CONTACT_ID -------------------- ---------- Panic Destination 1 SQL> select recid, contact_group_name from rhn_contact_groups; RECID CONTACT_GROUP_NAME ---------- ------------------------------ 1 Panic Destination 2 method1 SQL> select contact_group_id, member_contact_method_id from rhn_contact_group_members; CONTACT_GROUP_ID MEMBER_CONTACT_METHOD_ID ---------------- ------------------------ 1 1 So, it looks like the bug is in user deletion, which calls delete_user sql procedure - code/src/com/redhat/rhn/manager/user/UserManager.java: ...... /** * Deletes a User * @param loggedInUser The user doing the deleting * @param targetUid The id for the user we're deleting */ public static void deleteUser(User loggedInUser, Long targetUid) { if (!loggedInUser.hasRole(RoleFactory.ORG_ADMIN)) { throw new PermissionException("deleteuser", "Deleting a user requires an Org Admin."); } CallableMode m = ModeFactory.getCallableMode("User_queries", "delete_user"); Map inParams = new HashMap(); Map outParams = new HashMap(); inParams.put("user_id", targetUid); m.execute(inParams, outParams); } ...... Within delete_user there are these 2 lines: delete from rhn_contact_methods where contact_id = user_id_in; delete from rhn_contact_groups where customer_id = our_org_id; 2nd one being part of a loop in deleting servers. The rhn_contact_groups deletion should probably be called regardless there're servers associated with the user or not. Xixi ------- Actually, should probably take recid and/or contact_group_name into account when deleting users, since customer_id is/maybe the same - RECID CONTACT_GROUP_NAME CUSTOMER_ID ---------- ------------------------------ ----------- 1 Panic Destination 1 2 method1 1 Xixi
Fix committed ee0a6174027cd00460b4da6f28d4c2fde4241438, including schema upgrade script.
verified proper rows are now removed. BEFORE: SQL> select recid, method_name, email_address from rhn_contact_methods; RECID METHOD_NAME ---------- -------------------- EMAIL_ADDRESS -------------------------------------------------- 1 email 2 testuseremail jesusr SQL> select recid, contact_group_name from rhn_contact_groups; RECID CONTACT_GROUP_NAME ---------- ------------------------------ 1 email 2 testuseremail AFTER: SQL> select recid, method_name, email_address from rhn_contact_methods; RECID METHOD_NAME ---------- -------------------- EMAIL_ADDRESS -------------------------------------------------- 1 email SQL> select recid, contact_group_name from rhn_contact_groups; RECID CONTACT_GROUP_NAME ---------- ------------------------------ 1 email
Spacewalk has been released for some time.