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

openstack_compute_instance_v2 block_device not removed. #6473

Closed
vmorris opened this issue May 4, 2016 · 9 comments · Fixed by #6921
Closed

openstack_compute_instance_v2 block_device not removed. #6473

vmorris opened this issue May 4, 2016 · 9 comments · Fixed by #6921
Labels

Comments

@vmorris
Copy link

vmorris commented May 4, 2016

Terraform Version

Terraform v0.6.16-dev (507ae65)

Affected Resource(s)

  • openstack_compute_instance_v2

Debug Output

https://gist.github.com/vmorris/6ff907bab20c61a4a9a0de093d82c8dd

Expected Behavior

Boot volume should be removed following a destroy.

Actual Behavior

Boot volume persists following a destroy.

Steps to Reproduce

  1. Create new openstack instance with boot from new volume (copied from image)
  block_device  {
    uuid = "${var.image_id_ubuntu}"
    source_type = "image"
    destination_type = "volume"
    boot_index = 0
    volume_size = 10
  }
  1. terraform apply
  2. Modify block_device to delete on terminate
  block_device  {
    uuid = "${var.image_id_ubuntu}"
    source_type = "image"
    destination_type = "volume"
    boot_index = 0
    volume_size = 10
    delete_on_termination = true
  }
  1. terraform apply
  2. terraform destroy

Comments

This is a complex use case, just getting it documented for posterity. I am not aware of any option in openstack to alter the on-terminate settings post-deploy but the terraform behaviour tends to imply that one could. Probably terraform should just enforce whatever option was set during the first apply that created the instance.

@jtopjian
Copy link
Contributor

jtopjian commented May 5, 2016

@vmorris This is a good catch.

It should be possible to add a check in the resource's Update function to return an error rather than accepting the change.

@vmorris
Copy link
Author

vmorris commented May 5, 2016

@jtopjian I have to admit, I'm just learning terraform.. I see the update function but not sure what would be required. I'll defer this until later, or if someone can drop a PR, I'd like to review.

Thanks!

@jtopjian
Copy link
Contributor

jtopjian commented May 5, 2016

@vmorris I should be able to tackle this in the next week. I'll keep you updated.

@jtopjian
Copy link
Contributor

@vmorris Sorry for the delay.

Please see #6921. I opted to follow the behavior of the aws_instance resource and trigger a destroy and recreate of the instance when any of the block_device arguments are changed.

Thoughts?

@vmorris
Copy link
Author

vmorris commented May 30, 2016

It's definitely possible to add and remove block devices in openstack without recreating the guest.. I could understand doing this if the block device that's being altered is the boot device, but why recreate otherwise?

@jtopjian
Copy link
Contributor

The name block_device can be confusing. Just to make sure we're on the same page, block_device in the openstack_compute_instance_v2 resource is managed by the os-volumes_boot API extension. Perhaps it should have been called boot_device, but it's possible to create more than one block_device, so maybe ephemeral_device. Anyway, the important thing is that this is entirely separate from attaching and detaching volumes.

Unfortunately I'm unable to find good documentation on os-volumes_boot in order to see how an instance can have its boot / ephemeral disks updated after creation. Do you know what commands or API calls are used? If so, I can look at adding support in Gophercloud and then Terraform.

But if there's not a way to alter the boot / ephemeral volumes, then I think it makes sense to just rebuild the entire instance upon any modification to the block_device argument/attribute.

@vmorris
Copy link
Author

vmorris commented May 31, 2016

Hmm, yes thanks for the clarification.
I'm afraid I don't have much information on the matter. The os-volumes_boot API extension is definitely not well documented. From what I gathered today the documentation regressed at some point and there appears to be some gaps now.

@jtopjian
Copy link
Contributor

OK, sounds good. I'm going to proceed with the ForceNew patch. This was actually the originally intended behavior (as can be seen by ForceNew in the block_device attributes), but looks like it didn't take effect when its child arguments were changed. As mentioned, it also matches the AWS EC2 behavior.

If it's discovered that boot/ephemeral devices can be cleanly modified after creation, a subsequent patch can be merged that supports it.

@ghost
Copy link

ghost commented Apr 25, 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 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants