From d8f99d114fc1f8dd2968d353e9aadd82e78fede7 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Tue, 27 May 2014 11:18:37 -0700 Subject: don't infinite loop on umounting the filesystem --- lib/chef/provider/mount.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb index 34b924d3c6..c80855c5a7 100644 --- a/lib/chef/provider/mount.rb +++ b/lib/chef/provider/mount.rb @@ -69,7 +69,7 @@ class Chef umount_fs Chef::Log.info("#{new_resource} unmounted") end - sleep 0.1 while mounted? + wait_until_unmounted converge_by("mount #{current_resource.device}") do mount_fs Chef::Log.info("#{new_resource} mounted") @@ -147,6 +147,17 @@ class Chef def disable_fs raise Chef::Exceptions::UnsupportedAction, "#{self.to_s} does not support :disable" end + + private + + def wait_until_unmounted(tries = 20) + while mounted? + if (tries -= 1) == 0 + raise Chef::Exceptions::Mount, "Retries exceeded waiting for filesystem to unmount" + end + sleep 0.1 + end + end end end end -- cgit v1.2.1