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