Bug 1135913

Summary: cibadmin writes the CIB to disk even if the CIB was not changed when using CIB_file
Product: Red Hat Enterprise Linux 7 Reporter: Tomas Jelinek <tojeline>
Component: pacemakerAssignee: Andrew Beekhof <abeekhof>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: abeekhof, cluster-maint, dvossel, jkortus, mnovacek, tlavigne
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pacemaker-1.1.12-4 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 10:00:21 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:

Description Tomas Jelinek 2014-09-01 07:34:57 UTC
Description of problem:
When specifying the cib file location using the environment variable CIB_file, cibadmin writes the cib to disk even if the cib has not been changed e.g. on --query command.

Version-Release number of selected component (if applicable):
pacemaker-1.1.10-29.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. dump cib to a file
# pcs cluster cib /root/mycib.xml

2. check the time
# ls -l /root/mycib.xml
-rw------- 1 root root 9778 Aug 29 14:34 /root/mycib.xml
# head -n 1 /root/mycib.xml
<cib admin_epoch="0" cib-last-written="Fri Aug 29 14:34:23 2014" crm_feature_set="3.0.7" epoch="6439" have-quorum="1" num_updates="3" update-client="cibadmin" update-origin="rh70-node1" validate-with="pacemaker-1.2" dc-uuid="1">

3. get the content of the cib using CIB_file
# CIB_file=/root/mycib.xml cibadmin -Ql
<cib admin_epoch="0" cib-last-written="Fri Aug 29 14:34:23 2014" crm_feature_set="3.0.7" epoch="6439" have-quorum="1" num_updates="3" update-client="cibadmin" update-origin="rh70-node1" validate-with="pacemaker-1.2" dc-uuid="1">
{output truncated}

4. check the time again to see that it has been changed
# ls -l /root/mycib.xml
-rw------- 1 root root 9778 Aug 29 14:35 /root/mycib.xml
# head -n 1 /root/mycib.xml
<cib admin_epoch="0" cib-last-written="Fri Aug 29 14:35:34 2014" crm_feature_set="3.0.7" epoch="6439" have-quorum="1" num_updates="3" update-client="cibadmin" update-origin="rh70-node1" validate-with="pacemaker-1.2" dc-uuid="1"> 

Actual results:
Querying the cib overwrites the cib file.

Expected results:
Cibadmin should not overwrite the cib file nor update it in any way when cib has not been changed / a read-only operation has been requested.

Comment 2 Andrew Beekhof 2014-09-02 07:34:04 UTC
Upstream fix:
   https://github.com/beekhof/pacemaker/commit/31e24ca

    Fix: cib: Do not update on disk backups if we're just querying them
    
    Previously users of CIB_file would see their files' last-written
    attribute updated, thus invalidating the saved digest.

We'll pick it up in the rebase

Comment 4 Andrew Beekhof 2015-01-07 04:00:15 UTC
Hmm, looks like the flags wouldn't allow it to be added

Comment 7 michal novacek 2015-01-08 13:44:09 UTC
I have verified that cibfile is not updated when requiring only read-only
action with pacemaker-1.1.12-15.el7.x86_64

-----

[root@virt-071 ~]# date 
Thu Jan 8 14:33:27 CET 2015

[root@virt-071 ~]# pcs cluster cib /tmp/a.xml && date
Thu Jan 8 14:33:42 CET 2015

[root@virt-071 ~]# head -n 1 /tmp/a.xml 
<cib admin_epoch="0" cib-last-written="Mon Jan  5 16:23:30 2015" crm_feature_set="3.0.9" dc-uuid="2" epoch="43" have-quorum="1" num_updates="26" validate-with="pacemaker-2.2">

[root@virt-071 ~]# CIB_file=/tmp/a.xml cibadmin -Ql | head -n 1
<cib admin_epoch="0" cib-last-written="Mon Jan  5 16:23:30 2015" crm_feature_set="3.0.9" dc-uuid="2" epoch="43" have-quorum="1" num_updates="26" validate-with="pacemaker-2.2">

[root@virt-071 ~]# date 
Thu Jan 8 14:35:01 CET 2015

[root@virt-071 ~]# ls -l /tmp/a.xml 
-rw-r--r--. 1 root root 48904 Jan 8 14:33 /tmp/a.xml

[root@virt-071 ~]# head -n 1 /tmp/a.xml 
<cib admin_epoch="0" cib-last-written="Mon Jan  5 16:23:30 2015" crm_feature_set="3.0.9" dc-uuid="2" epoch="43" have-quorum="1" num_updates="26" validate-with="pacemaker-2.2">

[root@virt-071 ~]# rpm -q pacemaker
pacemaker-1.1.12-15.el7.x86_64

Comment 9 errata-xmlrpc 2015-03-05 10:00:21 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/RHBA-2015-0440.html