Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip the boot disk on gce during backup #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libraries/provider_rightscale_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,10 @@ def get_instance_href
def get_volume_attachment_hrefs
attachments = @api_client.volume_attachments.index(:filter => ["instance_href==#{get_instance_href}"])

# Reject attachments whose device parameter is set to 'unknown'
attachments.reject! { |attachment| attachment.device == 'unknown' }
# Reject attachments whose device parameter is set to 'unknown'. Also skip the boot disk on gce.
attachments.reject! do |attachment|
attachment.device == 'unknown' || attachment.resource_uid =~ /\/disks\/boot-/
end
attachments.map { |attachment| attachment.href }
end

Expand Down
22 changes: 21 additions & 1 deletion spec/unit_test/provider_rightscale_backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,19 @@
attachment.stub(
:state => 'available',
:device => 'some_device',
:href => 'some_href'
:href => 'some_href',
:resource_uid => 'v-123456'
)
attachment
end

let(:boot_volume_attachment_stub) do
attachment = double('volume_attachment')
attachment.stub(
:state => 'available',
:device => 'some_device',
:href => 'some_href',
:resource_uid => 'projects/example.com:test/disks/boot-i-12345'
)
attachment
end
Expand Down Expand Up @@ -328,6 +340,14 @@ def create_test_volume_type(name, href)
attachment_hrefs = provider.send(:get_volume_attachment_hrefs)
attachment_hrefs.should be_a_kind_of(Array)
end

it "should skip the boot disk attached to the instance" do
client_stub.should_receive(:volume_attachments).and_return(volume_attachment_resource)
volume_attachment_resource.should_receive(:index).and_return([boot_volume_attachment_stub])
attachment_hrefs = provider.send(:get_volume_attachment_hrefs)
attachment_hrefs.should be_a_kind_of(Array)
attachment_hrefs.should be_empty
end
end

describe "#get_cloud_href" do
Expand Down