From 9847e38ec0947029eab9b1ed7953684aa56b3619 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Wed, 14 May 2014 14:05:35 -0400 Subject: [PATCH] use --wait with crm resource start/stop to avoid races https://mailman.suse.de/mailman/private/ha-devel/2014-May/003603.html (sorry - SUSE internal-only mailing list; but thread available on request) --- libraries/pacemaker/resource.rb | 4 ++-- spec/helpers/runnable_resource.rb | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/pacemaker/resource.rb b/libraries/pacemaker/resource.rb index 8eae3eb..1a0e51e 100644 --- a/libraries/pacemaker/resource.rb +++ b/libraries/pacemaker/resource.rb @@ -17,11 +17,11 @@ module Pacemaker end def crm_start_command - "crm --force resource start '#{name}'" + "crm --force --wait resource start '#{name}'" end def crm_stop_command - "crm --force resource stop '#{name}'" + "crm --force --wait resource stop '#{name}'" end # CIB object definitions look something like: diff --git a/spec/helpers/runnable_resource.rb b/spec/helpers/runnable_resource.rb index b6d8a5c..d6ec906 100644 --- a/spec/helpers/runnable_resource.rb +++ b/spec/helpers/runnable_resource.rb @@ -69,7 +69,7 @@ shared_examples "a runnable resource" do |fixture| describe ":start action" do it_should_behave_like "action on non-existent resource", \ :start, - "crm --force resource start #{fixture.name}", \ + "crm --force --wait resource start #{fixture.name}", \ "Cannot start non-existent #{fixture}" it "should do nothing to a started resource" do @@ -78,7 +78,7 @@ shared_examples "a runnable resource" do |fixture| provider.run_action :start - cmd = "crm --force resource start #{fixture.name}" + cmd = "crm --force --wait resource start #{fixture.name}" expect(@chef_run).not_to run_execute(cmd) expect(@resource).not_to be_updated end @@ -90,7 +90,7 @@ shared_examples "a runnable resource" do |fixture| provider.run_action :start - cmd = "crm --force resource start '#{fixture.name}'" + cmd = "crm --force --wait resource start '#{fixture.name}'" expect(@chef_run).to run_execute(cmd) expect(@resource).to be_updated end @@ -99,7 +99,7 @@ shared_examples "a runnable resource" do |fixture| describe ":stop action" do it_should_behave_like "action on non-existent resource", \ :stop, - "crm --force resource stop #{fixture.name}", \ + "crm --force --wait resource stop #{fixture.name}", \ "Cannot stop non-existent #{fixture}" it "should do nothing to a stopped resource" do @@ -108,7 +108,7 @@ shared_examples "a runnable resource" do |fixture| provider.run_action :stop - cmd = "crm --force resource start #{fixture.name}" + cmd = "crm --force --wait resource start #{fixture.name}" expect(@chef_run).not_to run_execute(cmd) expect(@resource).not_to be_updated end @@ -119,7 +119,7 @@ shared_examples "a runnable resource" do |fixture| provider.run_action :stop - cmd = "crm --force resource stop '#{fixture.name}'" + cmd = "crm --force --wait resource stop '#{fixture.name}'" expect(@chef_run).to run_execute(cmd) expect(@resource).to be_updated end