cloud-ca / terraform-provider-cloudca

Terraform provider for cloud.ca
https://cloud.ca
MIT License
8 stars 10 forks source link

Cannot delete volumes which are attached to instances #40

Open archyufa opened 7 years ago

archyufa commented 7 years ago

We noticed following behaviour of terraform cloudca provider: Action: 1). Create 1 instance with 1 attached volume using terraform 2). Mount FS on it, via cloudinit or by manually formatting and adding to /etc/fstab 3). Destroy with terraform.

Result: Terraform fails to delete volumes due it can not detach volume from VM. It seems this behaviour is expected in CloudStack/cloudca, as a protection mechanism, however it will be good to have a forceful way to detach and delete VM.

Found in version: Terraform v0.8.6 terraform-provider-cloudca v1.0

Workaround: Stop VM and Destroy. However this will not scale if you have a huge set of resources.

Full error message printout:


cloudca_instance.lab-node.1: Refreshing state... (ID: d8ec4a23-449f-4b41-928e-341083bbf62e)
cloudca_volume.drive_1.0: Refreshing state... (ID: 74f2710c-e7ad-40f4-ad45-94bcf8430a32)
cloudca_volume.drive_1.0: Destroying...
Error applying plan:

1 error(s) occurred:

* cloudca_volume.drive_1.0: [ERROR] Received HTTP status code 400
[ERROR] Error Code: 2705, Message: Cannot delete volumes which are attached to instances. Detach this volume from its instance to delete., Context: {"instanceId":"4af766a9-f903-46bd-9b36-fa86e9152063"}

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.```