Openstack: "Attempt to boot from volume - no image" (forces new resource)

566 views
Skip to first unread message

Sean Boran

unread,
Jul 26, 2017, 7:47:34 AM7/26/17
to Terraform
Hi,

When creating a VM with the openstack provider (mitaka), "apply" always causes the VM to be recreated, even though its was created correctly.
TF 0.9.11

In the plan one sees:

    image_id:                             "Attempt to boot from volume - no image supplied" => "b2390ce1-475e-46ea-8b3e-cb3c6d28be03" (forces new resource)

The disk is configured as
  block_device {
    uuid                  = "${lookup(var.image, var.region)}"
    source_type           = "image"
    volume_size           = 16 
    boot_index            = 0
    destination_type      =  "volume" 
    delete_on_termination = true
  }

which corresponds to the "Boot From Volume" section on https://www.terraform.io/docs/providers/openstack/r/compute_instance_v2.html.

More details from the plan:
-/+ openstack_compute_instance_v2.terravm
 ..
    all_metadata.%:                       "2" => "<computed>"
    availability_zone:                    "nova" => "<computed>"
    block_device.#:                       "1" => "1"
    block_device.0.boot_index:            "0" => "0"
    block_device.0.delete_on_termination: "true" => "true"
    block_device.0.destination_type:      "volume" => "volume"
    block_device.0.source_type:           "image" => "image"
    block_device.0.uuid:                  "b2390ce1-475e-46ea-8b3e-cb3c6d28be03" => "b2390ce1-475e-46ea-8b3e-cb3c6d28be03"
    block_device.0.volume_size:           "16" => "16"
    flavor_id:                            "2226490a-3272-4a2b-9aaf-4e3712fdddb9" => "<computed>"
    flavor_name:                          "1GB-1cpu" => "1GB-1cpu"
    floating_ip:                          "10.98.181.163" => "10.98.181.163"
    force_delete:                         "false" => "false"
    image_id:                             "Attempt to boot from volume - no image supplied" => "b2390ce1-475e-46ea-8b3e-cb3c6d28be03" (forces new resource)
    image_name:                           "" => "<computed>"
 ..    name:                                 "terravm" => "terravm"
    network.#:                            "1" => "1"
    network.0.access_network:             "false" => "false"
    network.0.fixed_ip_v4:                "10.7.98.144" => "<computed>"
    network.0.fixed_ip_v6:                "" => "<computed>"
    network.0.floating_ip:                "10.98.181.163" => "<computed>"
    network.0.mac:                        "fa:16:3e:1a:7a:b1" => "<computed>"
    network.0.port:                       "" => "<computed>"
    network.0.uuid:                       "9c93ee2e-8edd-4a26-90bb-61102175bc16" => "<computed>"
    region:                               "RegionOne" => "RegionOne"
    security_groups.#:                    "1" => "1"
    security_groups.3814588639:           "default" => "default"
    stop_before_destroy:                  "false" => "false"

Is it perhaps the uuid that  needs to be generated in a different way?

Thanks in advance

Joe Topjian

unread,
Jul 26, 2017, 10:46:40 AM7/26/17
to terrafo...@googlegroups.com
Hi Sean,

Are you able to provide the full configuration?

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/f0f813f7-d03c-4a3b-b53b-4261851d36d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sean Boran

unread,
Jul 26, 2017, 11:33:57 AM7/26/17
to Terraform
Joe,

Not sure if its helps, there are many variables.

resource "openstack_compute_floatingip_v2" "float_ip" {
  region = "${var.region}"
  pool   = "${lookup(var.pub_net_id, var.region)}"
  count = "${ var.nb_of_nodes }"
}

resource "openstack_compute_instance_v2" "terravm" {
  name        = "${var.vmname}"
  count       = "${var.nb_of_nodes}"
  key_pair    = "${var.ssh_key_name}"
  region      = "${var.region}"
  flavor_name = "${var.flavor}"
  image_id    = "${lookup(var.image, var.region)}"

  # boot device on a volume i.e. will survive a computer node reboot
  block_device {
    uuid                  = "${lookup(var.image, var.region)}"
    source_type           = "image"
    volume_size           = 16 
    boot_index            = 0
    destination_type      = "${ var.volume_enable==1 ? "volume" : "local" }"
    delete_on_termination = true
  }

  security_groups = "${var.security_groups}"
   # then some remote execs, not included.
....


The creating logs show the variables substituted:
openstack_compute_floatingip_v2.float_ip: Creating...
  address:     "" => "<computed>"
  fixed_ip:    "" => "<computed>"
  instance_id: "" => "<computed>"
  pool:        "" => "Standard-IDC-foo"
  region:      "" => "RegionOne"
openstack_compute_floatingip_v2.float_ip: Creation complete (ID: 09fac7b7-6841-4d7a-96fc-db2d1351f847)
openstack_compute_instance_v2.terravm: Creating...
  access_ip_v4:                         "" => "<computed>"
  access_ip_v6:                         "" => "<computed>"
  all_metadata.%:                       "" => "<computed>"
  availability_zone:                    "" => "<computed>"
  block_device.#:                       "" => "1"
  block_device.0.boot_index:            "" => "0"
  block_device.0.delete_on_termination: "" => "true"
  block_device.0.destination_type:      "" => "volume"
  block_device.0.source_type:           "" => "image"
  block_device.0.uuid:                  "" => "b2390ce1-475e-46ea-8b3e-cb3c6d28be03"
  block_device.0.volume_size:           "" => "16"
  flavor_id:                            "" => "<computed>"
  flavor_name:                          "" => "1GB-1cpu"
  floating_ip:                          "" => "10.98.11.163"
  force_delete:                         "" => "false"
  image_id:                             "" => "b2390ce1-475e-46ea-8b3e-cb3c6d28be03"
  image_name:                           "" => "<computed>"
  key_pair:                             "" => "foo-jump"
  name:                                 "" => "terravm"
  network.#:                            "" => "1"
  network.0.access_network:             "" => "false"
  network.0.fixed_ip_v4:                "" => "<computed>"
  network.0.fixed_ip_v6:                "" => "<computed>"
  network.0.floating_ip:                "" => "<computed>"
  network.0.mac:                        "" => "<computed>"
  network.0.name:                       "" => "foo_net1"
  network.0.port:                       "" => "<computed>"
  network.0.uuid:                       "" => "<computed>"
  region:                               "" => "RegionOne"
  security_groups.#:                    "" => "1"
  security_groups.3814588639:           "" => "default"
  stop_before_destroy:                  "" => "false"
...
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
..
Outputs:
ip = 10.98.11.163
vmname = terravm


Have you enough info there?

Thanks,

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

Joe Topjian

unread,
Jul 26, 2017, 11:37:30 AM7/26/17
to terrafo...@googlegroups.com
Thanks, Sean.

Have you tried omitting `image_id`? It's not required when booting from a volume.

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/5823b2eb-6a90-444d-9707-32c01da0bfbc%40googlegroups.com.

Sean Boran

unread,
Jul 26, 2017, 12:30:47 PM7/26/17
to Terraform

Yipee, that works.

terraform apply
openstack_compute_floatingip_v2.float_ip: Refreshing state... (ID: 0f202e25-c4e4-4c52-9b3d-4a8635b0623f)
openstack_compute_instance_v2.terravm: Refreshing state... (ID: ba55da53-08e6-4a3b-9623-8966bfc60289)
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Thanks very much!

Sean

Sean Boran

unread,
Jul 28, 2017, 2:29:30 AM7/28/17
to Terraform

Just realized: that break ephemeral volumes. i.e. where volume_enable=0

I can fix that by adding:
image_id    = "${ var.volume_enable==1 ? lookup(var.image, var.region) : "" }"

However, that does not work for volume_enable=1, the resources are constantly destroy.
Any suggestions for that? It seems that for volume storage  image_id may not be specified, even if empty.

Sean

Sean Boran

unread,
Jul 28, 2017, 3:18:58 AM7/28/17
to Terraform

Correction: in fact that works, just a little bug in my code:

image_id    = "${ var.volume_enable==1 ? "" : lookup(var.image, var.region) }"

:-)

Sean
Reply all
Reply to author
Forward
0 new messages