Bug 468016 - RHN Satellite - duplicate notification methods
RHN Satellite - duplicate notification methods
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: Server (Show other bugs)
0.2
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jesus M. Rodriguez
Red Hat Satellite QA List
:
Depends On:
Blocks: space03
  Show dependency treegraph
 
Reported: 2008-10-22 08:55 EDT by Jan Pazdziora
Modified: 2009-09-17 03:02 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-09-17 03:02:21 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2008-10-22 08:55:19 EDT
+++ 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
Comment 1 Jan Pazdziora 2008-10-22 08:56:26 EDT
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
Comment 2 Jan Pazdziora 2008-10-22 09:12:32 EDT
Fix committed ee0a6174027cd00460b4da6f28d4c2fde4241438, including schema upgrade script.
Comment 3 Jesus M. Rodriguez 2008-11-04 13:14:19 EST
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@xxxxx.com

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
Comment 4 Miroslav Suchý 2009-09-17 03:02:21 EDT
Spacewalk has been released for some time.

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