| Summary: | fence_scsi: need stricter regular expression when looking for specific keys | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Ryan O'Hara <rohara> | ||||
| Component: | fence-agents | Assignee: | Ryan O'Hara <rohara> | ||||
| Status: | CLOSED ERRATA | QA Contact: | Cluster QE <mspqa-list> | ||||
| Severity: | high | Docs Contact: | |||||
| Priority: | low | ||||||
| Version: | 6.1 | CC: | cluster-maint, djansa, fdinitto | ||||
| Target Milestone: | rc | ||||||
| Target Release: | --- | ||||||
| Hardware: | All | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | fence-agents-3.0.12-13.el6 | Doc Type: | Bug Fix | ||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2011-05-19 14:21:53 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Attachments: |
|
||||||
Created attachment 474324 [details]
Fix regular expression used to grep for specific registration keys.
Patch to fix problem described above.
Here is test of fence_scsi with patch:
# register key "11" with device /dev/sdb
% ./fence_scsi -o on -k 11 -d /dev/sdb
# list keys register with device /dev/sdb
sg_persist -i -k /dev/sdb
DELL MD3000 0617
Peripheral device type: disk
PR generation=0x20, 2 registered reservation keys follow:
0x11
# check to see if key "11" is registered with /dev/sdb
% ./fence_scsi -o status -k 11 -d /dev/sdb; echo $?
0 <-- correct
# check to see if key "2" is registered with /dev/sdb
% ./fence_scsi -o status -k 2 -d /dev/sdb; echo $?
2 <-- correct
# check to see if key "1" is registered with /dev/sdb
% ./fence_scsi -o status -k 1 -d /dev/sdb; echo $?
2 <-- correct
Pushed to RHEL6 branch. commit cecc4a5fd1e3f494d6f7cf2eeded1a5b77336336 [root@marathon-05 sbin]# ./fence_scsi -o on -k 11 -d /dev/sdb
Mar 29 11:08:25 fence_scsi: [debug] main::do_register_ignore (node_key=11, dev=/dev/sdb)
Mar 29 11:08:25 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
[root@marathon-05 sbin]# sg_persist -i -k /dev/sdb
WINSYS SA3478 347C
Peripheral device type: disk
PR generation=0x62, 1 registered reservation key follows:
0x11
[root@marathon-05 sbin]# ./fence_scsi -o status -k 11 -d /dev/sdb; echo $?
Mar 29 11:08:38 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
0
[root@marathon-05 sbin]# ./fence_scsi -o status -k 2 -d /dev/sdb; echo $?
Mar 29 11:08:45 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
2
[root@marathon-05 sbin]# ./fence_scsi -o status -k 1 -d /dev/sdb; echo $?
Mar 29 11:08:51 fence_scsi: [debug] main::do_reset (dev=/dev/sdb, status=0)
2
Verified in fence-agents-3.0.12-21.el6
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0745.html |
In fence_scsi, there are a handful of places where it will look to see if a specific key is registered for a device. Currently the code looks like this: my @keys = grep { /$node_key/ } get_registration_keys ($dev); This line of code will get all keys registered with a specific device and filter (grep) for the key we are interested in. The code typically then checks to see if @keys is empty. The problem is with the regular expression used for grep. It needs to be more specific to avoid false positives. An example: # register key "11" with device /dev/sdb % /usr/sbin/fence_scsi -o on -k 11 -d /dev/sdb # list keys register with device /dev/sdb sg_persist -i -k /dev/sdb DELL MD3000 0617 Peripheral device type: disk PR generation=0x20, 2 registered reservation keys follow: 0x11 # check to see if key "11" is registered with /dev/sdb % /usr/sbin/fence_scsi -o status -k 11 -d /dev/sdb; echo $? 0 <-- correct # check to see if key "2" is registered with /dev/sdb % /usr/sbin/fence_scsi -o status -k 2 -d /dev/sdb; echo $? 2 <-- correct # check to see if key "1" is registered with /dev/sdb /usr/sbin/fence_scsi -o status -k 1 -d /dev/sdb; echo $? 0 <-- incorrect In this example, fence_scsi is incorrectly reporting that key "1" is registered with /dev/sdb because the regular expression is not specific. This fix is simple -- use anchors to make the regular expression more specific: my @keys = grep { /^$node_key$/ } get_registration_keys ($dev);