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

Renaming "digitalocean_volume" raises "A volume that's attached to a Droplet cannot be deleted" #17964

Closed
ksanderer opened this issue Apr 29, 2018 · 2 comments

Comments

@ksanderer
Copy link

ksanderer commented Apr 29, 2018

Terraform Version

Terraform v0.11.7
+ provider.digitalocean v0.1.3
+ provider.external v1.0.0

Terraform Configuration Files

https://gist.github.com/ksanderer/30b6d0edd3518ea0a49088a795a5c9a7

Crash Output

Error: Error applying plan:

2 error(s) occurred:

* digitalocean_volume.hcmc_db: 1 error(s) occurred:

* digitalocean_volume.hcmc_db: Error creating Volume: POST https://api.digitalocean.com/v2/volumes: 409 (request "94fbb17b-b2a3-453c-a1d3-afb4d16b80ab") failed to create volume
* digitalocean_volume.hcmc_admin (destroy): 1 error(s) occurred:

* digitalocean_volume.hcmc_admin: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/fddc7fbd-4b70-11e8-a456-0242ac116408: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Expected Behavior

After changing digitalocean_volume name terraform should:

  1. detach the old volume
  2. delete the old volume
  3. create the new volume
  4. attach the new volume

Actual Behavior

Terraform trying to delete volume before detaching it from the droplet.

* digitalocean_volume.hcmc_admin: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/fddc7fbd-4b70-11e8-a456-0242ac116408: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Steps to Reproduce

  1. terraform init
  2. terraform apply
  3. rename digitalocean_volume name foo -> bar
  4. terraform apply

Apply log

digitalocean_volume.foo: Refreshing state... (ID: 7bd24a9e-4b73-11e8-8a8f-0242ac115908)
digitalocean_ssh_key.default: Refreshing state... (ID: 20353441)
digitalocean_droplet.droplet1: Refreshing state... (ID: 91509324)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
  - destroy

Terraform will perform the following actions:

  ~ digitalocean_droplet.droplet1
      volume_ids.#:  "1" => <computed>

  + digitalocean_volume.bar
      id:            <computed>
      droplet_ids.#: <computed>
      name:          "foo"
      region:        "ams3"
      size:          "1"

  - digitalocean_volume.foo


Plan: 1 to add, 1 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

digitalocean_volume.foo: Destroying... (ID: 7bd24a9e-4b73-11e8-8a8f-0242ac115908)
digitalocean_volume.bar: Creating...
  droplet_ids.#: "" => "<computed>"
  name:          "" => "foo"
  region:        "" => "ams3"
  size:          "" => "1"

Error: Error applying plan:

2 error(s) occurred:

* digitalocean_volume.bar: 1 error(s) occurred:

* digitalocean_volume.bar: Error creating Volume: POST https://api.digitalocean.com/v2/volumes: 409 (request "708463e7-7fda-4d75-9b87-9d41537abc75") failed to create volume
* digitalocean_volume.foo (destroy): 1 error(s) occurred:

* digitalocean_volume.foo: Error deleting volume: DELETE https://api.digitalocean.com/v2/volumes/7bd24a9e-4b73-11e8-8a8f-0242ac115908: 409 A volume that's attached to a Droplet cannot be deleted. Please detach it first before deleting.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
@ghost
Copy link

ghost commented Apr 30, 2018

This issue has been automatically migrated to terraform-providers/terraform-provider-digitalocean#87 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to terraform-providers/terraform-provider-digitalocean#87.

@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants