From fe4d448938b602a91ada9c66b14a76d38e740f12 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Wed, 22 Feb 2017 14:59:56 +0100 Subject: [PATCH] Remove spurious CIB backup files There are some situations where we did not clean up CIB backup files correctly: 1) When a pcs show command was invoked 2) When we hit the maximum number of retries. 3) When the original file and the copy cib file are identical and we still called push_config() (very unlikely but we best clean that up) Let's remove these files in both of these cases. Closes-Bug: #1667145 Change-Id: I41404d569d81973c4b9531266c7a6c09904d1baf --- lib/puppet/provider/pcmk_common.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/puppet/provider/pcmk_common.rb b/lib/puppet/provider/pcmk_common.rb index 35fdd4a4..0a39ed38 100644 --- a/lib/puppet/provider/pcmk_common.rb +++ b/lib/puppet/provider/pcmk_common.rb @@ -30,6 +30,8 @@ def push_cib(cib) cib_orig_digest = Digest::SHA2.file("#{cib}.orig") if cib_digest == cib_orig_digest Puppet.debug("push_cib: #{cib} and #{cib}.orig were identical, skipping") + FileUtils.rm(cib, :force => true) + FileUtils.rm("#{cib}.orig", :force => true) return 0 end has_diffagainst = `/usr/sbin/pcs cluster cib-push --help`.include? 'diff-against' @@ -62,6 +64,8 @@ def pcs(name, resource_name, cmd, tries=1, try_sleep=0, Puppet.debug("#{try_text}/usr/sbin/pcs -f #{cib} #{cmd}") pcs_out = `/usr/sbin/pcs -f #{cib} #{cmd} 2>&1` if name.include?('show') + FileUtils.rm(cib, :force => true) + FileUtils.rm("#{cib}.orig", :force => true) # return output for good exit or false for failure. return $?.exitstatus == 0 ? pcs_out : false end @@ -74,6 +78,8 @@ def pcs(name, resource_name, cmd, tries=1, try_sleep=0, end Puppet.debug("Error: #{pcs_out}") if try == max_tries-1 + FileUtils.rm(cib, :force => true) + FileUtils.rm("#{cib}.orig", :force => true) pcs_out_line = pcs_out.lines.first ? pcs_out.lines.first.chomp! : '' raise Puppet::Error, "pcs -f #{cib} #{name} failed: #{pcs_out_line}" end