From cf461ece9ccc7909fcd9a62668a78f116437dd48 Mon Sep 17 00:00:00 2001 From: Lopaka Delp Date: Wed, 6 May 2015 16:18:50 -0700 Subject: [PATCH 1/4] ST-352 Add sleep/timeout on attaching volume --- libraries/provider_rightscale_volume.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/provider_rightscale_volume.rb b/libraries/provider_rightscale_volume.rb index 9d8920d..6a250a2 100644 --- a/libraries/provider_rightscale_volume.rb +++ b/libraries/provider_rightscale_volume.rb @@ -556,7 +556,15 @@ def attach_volume(volume_id, device) scan_for_attachments if node['virtualization']['system'] == 'vmware' # Determine the actual device name - (Set.new(get_current_devices) - current_devices).first + added_device = nil + Timeout::timeout(60) do + begin + sleep(1) + Chef::Log.info "Checking for added device." + added_device = (Set.new(get_current_devices) - current_devices).first + end until !added_device.nil? + end + added_device end # Finds volumes using the given filters. From 81f556161acfea0968c407193268f0824d098762 Mon Sep 17 00:00:00 2001 From: Lopaka Delp Date: Wed, 6 May 2015 16:32:57 -0700 Subject: [PATCH 2/4] ST-352 Bump version to 1.2.9 and update CHANGELOG. --- CHANGELOG.md | 5 +++++ metadata.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39cc82d..90f6c3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,11 @@ rightscale_volume Cookbook CHANGELOG This file is used to list changes made in each version of the rightscale_volume cookbook. +v1.2.9 +------ + +- Verify from OS perspective that volume has been attached. + v1.2.8 ------ diff --git a/metadata.rb b/metadata.rb index 062ac99..afae2c4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ license 'Apache 2.0' description 'Provides a resource to manage volumes on any cloud RightScale supports.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '1.2.8' +version '1.2.9' depends 'build-essential' From a3b8a5952aa4d47c49e3d86bb8da51cf6c94df4e Mon Sep 17 00:00:00 2001 From: Lopaka Delp Date: Sun, 10 May 2015 22:52:17 -0700 Subject: [PATCH 3/4] ST-352 Update rspec test to handle recent changes. --- spec/unit_test/provider_rightscale_volume_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/unit_test/provider_rightscale_volume_spec.rb b/spec/unit_test/provider_rightscale_volume_spec.rb index a329355..acb9316 100644 --- a/spec/unit_test/provider_rightscale_volume_spec.rb +++ b/spec/unit_test/provider_rightscale_volume_spec.rb @@ -626,9 +626,11 @@ def create_test_volume_type(name, id, size, href) end describe "#attach_volume" do + it "should attach the volume to an instance" do provider.stub(:find_volumes).and_return(array_of(volume_resource)) - provider.stub(:get_current_devices).and_return(['device_1', 'device_2']) + # First call will return 1 device, second call will return 2 devices. + provider.stub(:get_current_devices).and_return(['device_1'], ['device_1', 'device_2']) node.set[:virtualization][:system] = 'some_hypervisor' node.set['cloud']['provider'] = 'some_cloud' From eccd0c384d898842b12045d66963e19e264b1626 Mon Sep 17 00:00:00 2001 From: Lopaka Delp Date: Mon, 11 May 2015 14:22:52 -0700 Subject: [PATCH 4/4] ST-352 Remove 'not nil' condition. --- libraries/provider_rightscale_volume.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/provider_rightscale_volume.rb b/libraries/provider_rightscale_volume.rb index 6a250a2..733caf2 100644 --- a/libraries/provider_rightscale_volume.rb +++ b/libraries/provider_rightscale_volume.rb @@ -562,7 +562,7 @@ def attach_volume(volume_id, device) sleep(1) Chef::Log.info "Checking for added device." added_device = (Set.new(get_current_devices) - current_devices).first - end until !added_device.nil? + end until added_device end added_device end