summaryrefslogtreecommitdiff
path: root/lib/chef/provider/mount.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-05-27 11:36:03 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-05-28 16:59:27 -0700
commit29b0fb81525b5f5a1d198f0c3efae4357abf2d3a (patch)
tree4839cc590c3663ba5654e71f0c3964a98c25886e /lib/chef/provider/mount.rb
parentd8f99d114fc1f8dd2968d353e9aadd82e78fede7 (diff)
downloadchef-29b0fb81525b5f5a1d198f0c3efae4357abf2d3a.tar.gz
spec test the retry failure loop
- create an accessor for dependency injection - make sure that it raises when it runs out of retries
Diffstat (limited to 'lib/chef/provider/mount.rb')
-rw-r--r--lib/chef/provider/mount.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb
index c80855c5a7..b46604260e 100644
--- a/lib/chef/provider/mount.rb
+++ b/lib/chef/provider/mount.rb
@@ -27,6 +27,8 @@ class Chef
include Chef::Mixin::Command
+ attr_accessor :unmount_retries
+
def whyrun_supported?
true
end
@@ -35,6 +37,11 @@ class Chef
true
end
+ def initialize(new_resource, run_context)
+ super
+ self.unmount_retries = 20
+ end
+
def action_mount
unless current_resource.mounted
converge_by("mount #{current_resource.device} to #{current_resource.mount_point}") do
@@ -69,7 +76,7 @@ class Chef
umount_fs
Chef::Log.info("#{new_resource} unmounted")
end
- wait_until_unmounted
+ wait_until_unmounted(unmount_retries)
converge_by("mount #{current_resource.device}") do
mount_fs
Chef::Log.info("#{new_resource} mounted")
@@ -150,9 +157,9 @@ class Chef
private
- def wait_until_unmounted(tries = 20)
+ def wait_until_unmounted(tries)
while mounted?
- if (tries -= 1) == 0
+ if (tries -= 1) < 0
raise Chef::Exceptions::Mount, "Retries exceeded waiting for filesystem to unmount"
end
sleep 0.1