[Openstack Provider] Instance with volumes are not idempotent

454 views
Skip to first unread message

Rob Coward

unread,
Jun 22, 2016, 6:49:19 AM6/22/16
to Terraform
Hi,
I'm having a problem using the openstack provider to create an instance using volumes. Our openstack deploy defaults to using ephemeral disk, so to setup say a database server on persistent ceph-backed volume storage I'm trying to use the following:

resource "openstack_blockstorage_volume_v1" "db_system" {
  name
= "db_system"
  size
= 30
  image_id
= "${var.IMAGE_ID}"
  description
= "System volume for MySQL"
}


resource
"openstack_blockstorage_volume_v1" "db_data" {
  region
= ""
  name
= "db_data"
  description
= "data volume for MySQL"
  size
= 50
}


resource
"openstack_compute_instance_v2" "database" {
  name            
= "db01"
  flavor_name    
= "${var.INSTANCE_TYPE}"
  key_pair        
= "${openstack_compute_keypair_v2.ssh-keypair.name}"
  security_groups
= ["${openstack_networking_secgroup_v2.local_ssh.name}",
                     
"${openstack_networking_secgroup_v2.local_mysql.name}"]


  block_device
{
    uuid
= "${openstack_blockstorage_volume_v1.db_system.id}"
    source_type
= "volume"
    boot_index
= 0
    volume_size
= "${openstack_blockstorage_volume_v1.db_system.size}"
    destination_type
= "volume"
    delete_on_termination
= true
 
}


  volume
{
    volume_id
= "${openstack_blockstorage_volume_v1.db_data.id}"
 
}


  network
{
    name
= "${openstack_networking_network_v2.dmz.name}"
 
}
}

This works when the terraforrm apply is first run, however subsequent plans show:

~ openstack_compute_instance_v2.database
    volume
.#:                   "2" => "1"
    volume
.481488857.volume_id: "1e242a36-be4e-4afa-b9ad-26066f12fa31" => "1e242a36-be4e-4afa-b9ad-26066f12fa31"




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

and if I try another apply, i get the following error:

Error applying plan:


1 error(s) occurred:


* openstack_compute_instance_v2.database: Expected HTTP response code [202 204] when accessing [DELETE https://beta.openstack.skyscapecloud.com:13774/v2.1/51c7ec94d0a1420f9f55113dadbf2ec4/servers/02cee6da-298a-4f7e-968a-3ce81a0ebc4e/os-volume_attachments/1292ef21-3fa7-491c-ae93-c56131950cf8], but got 403 instead
{"forbidden": {"message": "Can't detach root device volume", "code": 403}}


Has anyone else come across this ? Is there a different approach I can use ?

Thanks in advance,
Rob Coward



Rob Coward

unread,
Jun 22, 2016, 9:09:51 AM6/22/16
to Terraform
After some more digging, it seems that if I remove the 2nd volume and just boot from the db_system volume, everything works as expected - it's something to do with having the additional volume attached to the VM that triggers the issue.

Joe Topjian

unread,
Jun 22, 2016, 6:00:10 PM6/22/16
to terrafo...@googlegroups.com
Hi Rob,

This definitely looks like a bug -- something about booting from a volume + attaching additional volumes is not being reported correctly.

Can you open a bug report / issue on Github? Please tag me (@jtopjian) and I'll take a look.

Thanks,
Joe

On Wed, Jun 22, 2016 at 7:09 AM, Rob Coward <r...@jive-videos.net> wrote:
After some more digging, it seems that if I remove the 2nd volume and just boot from the db_system volume, everything works as expected - it's something to do with having the additional volume attached to the VM that triggers the issue.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/66c8ebdf-5360-4762-9252-5eff47bbfd9c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Rob Coward

unread,
Jun 23, 2016, 5:36:45 AM6/23/16
to Terraform
Hi Joe,

Thanks
Rob
Reply all
Reply to author
Forward
0 new messages