Cannot create compute instance on openstack when configuring volume.

1,839 views
Skip to first unread message

John Smith

unread,
Jul 11, 2017, 10:02:21 PM7/11/17
to Terraform
Hi using the latest terraform download yesterday and OpenStack Ocata...

I have the following terraform file...

resource "openstack_blockstorage_volume_v2" "dcos_data" {
  count       = 1
  name        = "dcos_data"
  size        = 120
}

resource "openstack_compute_instance_v2" "dcos" {
  count           = 1
  name            = "dcos"
  image_name      = "CentOS 7 (64bit) (build 1704)"
  flavor_name     = "t2.xlarge"
  security_groups = ["default", "dcos"]
  #key_pair        = "dcos"
  user_data       = "${file("cloud-config")}"

#  volume {
#  }

  block_device {
    source_type           = "blank"
    destination_type      = "volume"
    volume_size           = 10
    boot_index            = 1
    delete_on_termination = true
  }

  network {
    name = "provider"
  }
}

But I keep getting this error... (Note the deprecated volume way works)


2017/07/11 21:53:05 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.
2017/07/11 21:53:05 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.
2017/07/11 21:53:05 [TRACE] [walkApply] Exiting eval tree: openstack_compute_instance_v2.dcos
Error applying plan:

1 error(s) occurred:

* openstack_compute_instance_v2.dcos: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.



Joe Topjian

unread,
Jul 11, 2017, 11:01:15 PM7/11/17
to terrafo...@googlegroups.com
Hi John,

You might be able to get a better error message by doing the following:

$ TF_LOG=DEBUG OS_DEBUG=1 terraform apply

That will print out all API requests and responses between you and the OpenStack environment. A response might contain a more descriptive error which might point to either a syntax problem, the OpenStack cloud not supporting a certain feature, or simply a bug. If it's the latter, definitely open an issue at https://github.com/terraform-providers/terraform-provider-openstack

Let me know if you have any questions.

Thanks,
Joe

--
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-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/f549aab4-795b-4e6a-b2c6-789c7d043ece%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Smith

unread,
Jul 11, 2017, 11:37:49 PM7/11/17
to Terraform
Still nothing on response... Except we see that UUID is passed blank...

2017/07/11 23:34:07 [DEBUG] plugin: terraform: openstack-provider (internal) 2017/07/11 23:34:07 [DEBUG] networks: [map[port: fixed_ip_v4: access_network:false uuid:c16c26f2-893e-4abc-9d11-5a323ece0883 name:provider]]
2017/07/11 23:34:07 [DEBUG] plugin: terraform: openstack-provider (internal) 2017/07/11 23:34:07 [DEBUG] Block Device Options: [{SourceType:blank UUID: BootIndex:1 DeleteOnTermination:true DestinationType:volume GuestFormat: VolumeSize:10}]
2017/07/11 23:34:07 [DEBUG] plugin: terraform: openstack-provider (internal) 2017/07/11 23:34:07 [DEBUG] Create Options: &bootfromvolume.CreateOptsExt{CreateOptsBuilder:(*servers.CreateOpts)(0xc4206e4480), BlockDevice:[]bootfromvolume.BlockDevice{bootfromvolume.BlockDevice{SourceType:"blank", UUID:"", BootIndex:1, DeleteOnTermination:true, DestinationType:"volume", GuestFormat:"", VolumeSize:10}}}
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalWriteState
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalApplyProvisioners
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalIf
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalWriteState
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalWriteDiff
2017/07/11 23:34:08 [DEBUG] root: eval: *terraform.EvalApplyPost
2017/07/11 23:34:08 [ERROR] root: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.
2017/07/11 23:34:08 [ERROR] root: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.
2017/07/11 23:34:08 [TRACE] [walkApply] Exiting eval tree: openstack_compute_instance_v2.dcos
2017/07/11 23:34:08 [DEBUG] dag/walk: upstream errored, not walking "provider.openstack (close)"
2017/07/11 23:34:08 [DEBUG] dag/walk: upstream errored, not walking "meta.count-boundary (count boundary fixup)"
2017/07/11 23:34:08 [DEBUG] dag/walk: upstream errored, not walking "root"
Error applying plan:

1 error(s) occurred:

2017/07/11 23:34:08 [DEBUG] plugin: waiting for all plugin processes to complete...
* openstack_compute_instance_v2.dcos: 1 error(s) occurred:

* openstack_compute_instance_v2.dcos: Error creating OpenStack server: Invalid request due to incorrect syntax or missing required parameters.

2017/07/11 23:34:08 [DEBUG] plugin: terraform: openstack-provider (internal) 2017/07/11 23:34:08 [DEBUG] plugin: waiting for all plugin processes to complete...
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.
2017/07/11 23:34:08 [DEBUG] plugin: /Users/anastasiosangelidis/Documents/utils/hashicorp/terraform: plugin process exited

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.

Joe Topjian

unread,
Jul 11, 2017, 11:59:59 PM7/11/17
to terrafo...@googlegroups.com
Are you sure you passed the OS_DEBUG=1 flag in the command?

From reviewing the Terraform configuration you posted, there might be a few issues:

* It looks like you might be missing a root block_device (index = 0)
* If you're trying to reference the volume you created in the volume resource, you will need to specify the uuid of the volume (block_device.uuid)
* If you simply want to attach the volume (which is the new method that replaced the instance's volume block), you can use the openstack_compute_volume_attach_v2 resource.

Check out the examples for more details of how to do the above here:

https://www.terraform.io/docs/providers/openstack/r/compute_instance_v2.html

and let me know if you're still running into problems :)

Thanks,
Joe

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/0a7e3405-6737-4550-a546-12919d9e9207%40googlegroups.com.

John Smith

unread,
Jul 12, 2017, 12:19:05 AM7/12/17
to Terraform
Oh oops..


I'm trying to create a "data" volume to attach to the compute instance following the example: Boot Instance, Create Volume, and Attach Volume as a Block Device

resource "openstack_compute_instance_v2" "dcos" {
  count           = "${var.instance_count}"
  name            = "dcos-${count.index}"
  image_name      = "CentOS 7 (64bit) (build 1704)"
  flavor_name     = "t2.xlarge"
  security_groups = ["default", "dcos"]

#  volume {
#    #volume_id     = "${openstack_blockstorage_volume_v2.*.id}"
#    volume_id = "${ element(openstack_blockstorage_volume_v2.dcos_data.*.id, count.index)}"
#  }

  block_device {
    source_type           = "blank"
    destination_type      = "volume"
    volume_size           = 10
    boot_index            = 1
    delete_on_termination = true
  }

  network {
    name = "provider"
  }

  user_data = "${file("cloud-config")}"
}

John Smith

unread,
Jul 12, 2017, 12:26:39 AM7/12/17
to Terraform
What I mean to say. I want to create a "data" volume and then attach that as an extra disk to the VM. So do i need to use the attach resource instead?

John Smith

unread,
Jul 12, 2017, 12:28:07 AM7/12/17
to Terraform
Here is the error...

2017/07/12 00:27:23 [DEBUG] plugin: terraform:   "badRequest": {
2017/07/12 00:27:23 [DEBUG] plugin: terraform:     "code": 400,
2017/07/12 00:27:23 [DEBUG] plugin: terraform:     "message": "Block Device Mapping is Invalid: Boot sequence for the instance and image/block device mapping combination is not valid."

Joe Topjian

unread,
Jul 12, 2017, 1:01:50 AM7/12/17
to terrafo...@googlegroups.com
Right, if you choose to configure an instance using "block_device", you must also specify the root device first (you have to create a block_device with an index of 0 in addition to the volume you're trying to attach):

https://www.terraform.io/docs/providers/openstack/r/compute_instance_v2.html#boot-instance-create-volume-and-attach-volume-as-a-block-device

Note the two block_device entries. When you use block_device, you're effectively telling OpenStack how you want *all* disks to be laid out on the instance. The example in the above link uses a source_type of "image" and destination_type of "local" which is what OpenStack would have done if you chose not to use a block_device at all.

The big difference between block_device and attaching arbitrary volumes is that OpenStack will ensure that all block_devices are attached and ready to go before the instance goes to an ACTIVE state. Whereas attaching volumes will happen after the instance has become ACTIVE. One of the reasons for removing the "volume" block was to make this more explicit (although it's still a bit confusing).

To unsubscribe from this group and stop receiving emails from it, send an email to terraform-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/8af42842-8f98-47bc-8e8e-b1c6462d394a%40googlegroups.com.

John Smith

unread,
Jul 12, 2017, 2:28:19 PM7/12/17
to Terraform
Ok got it it works now...

John Smith

unread,
Jul 12, 2017, 2:28:27 PM7/12/17
to Terraform
Thanks
Reply all
Reply to author
Forward
0 new messages