aws icon indicating copy to clipboard operation
aws copied to clipboard

ebs_volume delete action fails due to device requirement

Open eedwardsdisco opened this issue 8 years ago • 5 comments

Cookbook version

3.3.3

Chef-client version

12.10.24

Platform Details

aws opsworks

Scenario:

aws_ebs_volume action :delete

Steps to Reproduce:

  aws_ebs_volume volume.volume_id do
    timeout 300
    volume_id volume.volume_id
    action :nothing
  end.run_action(:delete)

Expected Result:

delete succeeds

Actual Result:

Cookbook Trace:
---------------
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/aws/providers/ebs_volume.rb:154:in `currently_attached_volume'
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/aws/providers/ebs_volume.rb:136:in `determine_volume'
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/aws/providers/ebs_volume.rb:92:in `block in class_from_file'
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/myco-mycookbook/recipes/destroy_data.rb:114:in `block in from_file'
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/myco-mycookbook/recipes/destroy_data.rb:107:in `each'
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/myco-mycookbook/recipes/destroy_data.rb:107:in `from_file'

Relevant File Content:
----------------------
/var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/cookbooks/aws/providers/ebs_volume.rb:

147:  # Retrieves information for a volume
148:  def volume_by_id(volume_id)
149:    ec2.describe_volumes(volume_ids: [volume_id]).volumes[0]
150:  end
151:  
152:  # Returns the volume that's attached to the instance at the given device or nil if none matches
153:  def currently_attached_volume(instance_id, device)
154>>   ec2.describe_volumes(
155:      filters: [
156:        { name: 'attachment.device', values: [device] },
157:        { name: 'attachment.instance-id', values: [instance_id] }
158:      ]
159:    ).volumes[0]
160:  end
161:  
162:  # Returns true if the given volume meets the resource's attributes
163:  def volume_compatible_with_resource_definition?(volume)

Platform:
---------
x86_64-linux

[2016-06-04T22:54:56+00:00] ERROR: Running exception handlers
[2016-06-04T22:54:56+00:00] ERROR: Exception handlers complete
[2016-06-04T22:54:56+00:00] FATAL: Stacktrace dumped to /var/chef/runs/2da6ecfa-14ff-45ad-acef-df19741dd3dd/local-mode-cache/cache/chef-stacktrace.out
[2016-06-04T22:54:56+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-06-04T22:54:56+00:00] ERROR: aws_ebs_volume[vol-a2c49e10] (myco-mycookbook::destroy_data line 110) had an error: ArgumentError: expected params[:filters][0][:values][0] to be a string
[2016-06-04T22:54:56+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

eedwardsdisco avatar Jun 04 '16 23:06 eedwardsdisco

Additional Notes:

If I specify nil for the device, I get a warning about Chef 12 vs Chef 13 behavior and the upcoming deprecation of get vs set.

If I specify '' (an empty string), I don't get a warning and it succeeds.

Seems like I should be able to not have to specify device at all if I'm doing a :delete.

eedwardsdisco avatar Jun 05 '16 22:06 eedwardsdisco

I am encountering the same error message when attempting to execute the :snapshot action on an EBS volume. This occurred immediately after updating the version of the aws cookbook from version 2.7.2, to 2.9.2 in our environments. I am running chef-client version 12.6.0 .

Is it known whether this same behavior occurs in later versions of the aws cookbbok?

Should specifying a 'device' be required when creating a snapshot?

shanedownes avatar Jan 31 '17 22:01 shanedownes

I confirmed that specifying the device as an empty string, as mentioned above, resolves this issue, when executing the :snapshot action.

shanedownes avatar Feb 01 '17 21:02 shanedownes

This fails in a new/different way now. I've been looking into it. Thanks for reporting the issue.

iennae avatar Sep 13 '17 05:09 iennae

Any chance this can get fixed? I tried to delete a volume and it says "Cannot delete volume vol-XXXX as it is currently attached to 1 node(s)". If I'm deattaching it first, then I'm getting volume_id attribute not set and no volume id is set in the node data for this resource (which is populated by action :create) and no volume is attached at the device

Is there a way to deattach and delete the volume?

kivagant-ba avatar Sep 22 '21 02:09 kivagant-ba