Bug 468016
| Summary: | RHN Satellite - duplicate notification methods | ||
|---|---|---|---|
| Product: | [Community] Spacewalk | Reporter: | Jan Pazdziora (Red Hat) <jpazdziora> |
| Component: | Server | Assignee: | Jesus M. Rodriguez <jesusr> |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Red Hat Satellite QA List <satqe-list> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 0.2 | ||
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2009-09-17 07:02:21 UTC | Type: | --- |
| 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: | 456551 | ||
|
Description
Jan Pazdziora (Red Hat)
2008-10-22 12:55:19 UTC
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. |