Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1575973

Summary: fence_scsi duplicates entries in /var/run/cluster/fence_scsi.dev on attribute change
Product: Red Hat Enterprise Linux 7 Reporter: Ondrej Faměra <ofamera>
Component: fence-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.5CC: cluster-maint, mjuricek, mlisik
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: fence-agents-4.0.11-89.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 07:49:52 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:
Attachments:
Description Flags
proposed patch to fix the issue none

Description Ondrej Faměra 2018-05-08 12:46:39 UTC
Created attachment 1433197 [details]
proposed patch to fix the issue

== Description of problem:
When fence_scsi stonith device configuration is updated the content of '/var/run/cluster/fence_scsi.dev'
gets partially duplicated and grows over time.

== Version-Release number of selected component (if applicable):
fence-agents-scsi-4.0.11-86.el7.x86_64

== How reproducible:
always

== Steps to Reproduce:
1. Create fence_scsi stonith device in pacemaker cluster with at least 2 devices in 'device' attribute
  # pcs stonith create scsi fence_scsi devices="/dev/sdb,/dev/sdc"
2. Update the 'scsi' stonith device by adding a new disk to list
  # pcs stonith update scsi devices="/dev/sdb,/dev/sdc,/dev/sdd"

== Actual results:
Content of the file '/var/run/cluster/fence_scsi.dev'
# cat /var/run/cluster/fence_scsi.dev
/dev/sdb
/dev/sdc
/dev/sdc
/dev/sdd

== Expected results:
Content of the file '/var/run/cluster/fence_scsi.dev'
# cat /var/run/cluster/fence_scsi.dev
/dev/sdb
/dev/sdc
/dev/sdd

== Additional info:
Running more updates results in more duplicate entries inside the file.

For example in above situation adding another disk would result in following content:
# pcs stonith update scsi devices="/dev/sdb,/dev/sdc,/dev/sdd,/dev/sde"
# cat /var/run/cluster/fence_scsi.dev
/dev/sdb
/dev/sdc
/dev/sdc
/dev/sdd
/dev/sdc
/dev/sdd
/dev/sde

It seems that the function responsible for matching the device name doesn't match properly.
Applying following change to /usr/sbin/fence_scsi seems to resolve the problem and make the
devices to match properly.

--- /usr/sbin/fence_scsi	2018-02-07 16:53:44.000000000 +0100
+++ /usr/sbin/fence_scsi	2018-05-08 14:36:57.168000000 +0200
@@ -240,7 +240,7 @@
 	except IOError:
 		fail_usage("Failed: Cannot open file \""+ file_path + "\"")
 	out = f.read()
-	if not re.search(r"^" + dev + "\s+", out):
+	if not re.search(r"^" + dev + "\s+", out, flags=re.MULTILINE):
 		f.write(dev + "\n")
 	f.close()

Comment 7 errata-xmlrpc 2018-10-30 07:49:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3031