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

ebs_volume delete action fails due to device requirement #244

Open
eedwardsdisco opened this issue Jun 4, 2016 · 5 comments
Open

ebs_volume delete action fails due to device requirement #244

eedwardsdisco opened this issue Jun 4, 2016 · 5 comments

Comments

@eedwardsdisco
Copy link

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
Copy link
Author

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.

@tas50 tas50 added the Type: Bug label Jan 4, 2017
@shanedownes
Copy link

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
Copy link

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

@iennae
Copy link
Contributor

iennae commented Sep 13, 2017

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

@kivagant-ba
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants