Bug 1175400

Summary: pcs resource op add creates duplicate op entires
Product: Red Hat Enterprise Linux 7 Reporter: Frank Danapfel <fdanapfe>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: low Docs Contact:
Priority: medium    
Version: 7.1CC: cluster-maint, rbinkhor, rsteiger, tojeline
Target Milestone: pre-dev-freeze   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.141-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: User adds a duplicate resource operation. Consequence: Duplicate operations specified for a resource. Fix: Added check for duplicate operations. Result: User is informed that a duplicate operation already exists, new duplicate operation is not created unless --force flag is used.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 09:33:56 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 fix none

Description Frank Danapfel 2014-12-17 16:15:51 UTC
Description of problem:
If "pcs resource op add" is executed without checking if the op already exists a duplicate op entry will be created

Version-Release number of selected component (if applicable):
pcs-0.9.123-9.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. run pcs op add for an already existing op of a resource
2.
3.

Actual results:
# pcs config
...

Resource: rsc_ip_SAPHana_DSG_HDB00 (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: ip=192.168.123.24 
  Operations: start interval=0s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-start-timeout-20s)
              stop interval=0s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-stop-timeout-20s)
              monitor interval=10s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-monitor-interval-10s)..
# pcs resource op add rsc_ip_SAPHana_DSG_HDB00 start timeout=3600
# pcs config
...
 Resource: rsc_ip_SAPHana_DSG_HDB00 (class=ocf provider=heartbeat type=IPaddr2)
  Attributes: ip=192.168.123.24 
  Operations: start interval=0s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-start-timeout-20s)
              stop interval=0s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-stop-timeout-20s)
              monitor interval=10s timeout=20s (rsc_ip_SAPHana_DSG_HDB00-monitor-interval-10s)
              start interval=0s timeout=3600 (rsc_ip_SAPHana_DSG_HDB00-name-start-timeout-3600)
...
Expected results:
pcs should give at leas a warning or offer the possibility to update the existing op entry for the resource instead of adding a new one.

Additional info:

Comment 2 Chris Feist 2014-12-22 21:22:00 UTC
There are some cases when we want to allow multiple operations, but most of the time that isn't what a user wants.

I think we just need to add a warning if a operation already exists with that name, and specifically an error if we attempt to add a monitor operation with the same interval (since pacemaker does not support that).

Comment 3 Tomas Jelinek 2015-01-05 14:35:47 UTC
There are patches in upstream for reporting an error when user attempts to add an operation with the same name and interval:
https://github.com/feist/pcs/commit/c97e96ab6361f15773bbd426babe7af192257999
https://github.com/feist/pcs/commit/40c0a774a453730c92600f4ece7c310e2d7dd2e7
https://github.com/feist/pcs/commit/abd1ecd1d1b24156a419257517c17a11a36152e5

They do not cover the case when user attempts to create more operations with the same name but different intervals.  We can add a check for that and print a warning.  It should be possible to create several monitor operations with different roles (or OCF_CHECK_LEVEL values) and different intervals though.

Comment 7 Tomas Jelinek 2015-06-18 13:20:20 UTC
Created attachment 1040492 [details]
proposed fix

Comment 8 Tomas Jelinek 2015-06-23 12:53:14 UTC
See also: bz1031141 comment 7

Before Fix:
[root@rh71-node1 ~]# rpm -q pcs
pcs-0.9.140-1.el7.x86_64
[root@rh71-node1:~]# pcs resource create dummy dummy
[root@rh71-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)
[root@rh71-node1:~]# pcs resource op add dummy monitor interval=20 timeout=20
[root@rh71-node1:~]# echo $?
0
[root@rh71-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)
              monitor interval=20 timeout=20 (dummy-monitor-interval-20)



After Fix:
[root@rh71-node1:~]# rpm -q pcs
pcs-0.9.141-1.el7.x86_64
[root@rh71-node1:~]# pcs resource create dummy dummy
[root@rh71-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)
[root@rh71-node1:~]# pcs resource op add dummy monitor interval=20 timeout=20
Error: operation monitor already specified for dummy, use --force to override:
monitor interval=10 timeout=20 (dummy-monitor-interval-10)
[root@rh71-node1:~]# echo $?
1
[root@rh71-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)
[root@rh71-node1:~]# pcs resource op add dummy monitor interval=20 timeout=20 --force
[root@rh71-node1:~]# echo $?
0
[root@rh71-node1:~]# pcs resource show dummy
 Resource: dummy (class=ocf provider=heartbeat type=Dummy)
  Operations: start interval=0s timeout=20 (dummy-start-interval-0s)
              stop interval=0s timeout=20 (dummy-stop-interval-0s)
              monitor interval=10 timeout=20 (dummy-monitor-interval-10)
              monitor interval=20 timeout=20 (dummy-monitor-interval-20)

Comment 12 errata-xmlrpc 2015-11-19 09:33:56 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://rhn.redhat.com/errata/RHSA-2015-2290.html