Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Terraform tries to change network settings of running compute instances if another is added #18

Open
0xErnie opened this issue Jan 23, 2018 · 1 comment

Comments

@0xErnie
Copy link

0xErnie commented Jan 23, 2018

Whenever I increase "instance_count" in the minimal example, terraform suggests that all compute instances should be "destroyed and recreated" and the fails applying this change.

I don't understand why running instances have to be destroyed and recreated and this should not fail.

Terraform v0.11.2 + provider.openstack v1.2.0

terraform apply -var-file=parameter.tvars

Warning: openstack_networking_router_v2.router: "external_gateway": [DEPRECATED] use external_network_id instead



openstack_compute_secgroup_v2.secgrp_web: Refreshing state... (ID: 77e7d61b-2170-41da-8b7c-bf562b3f904b)
openstack_networking_network_v2.network: Refreshing state... (ID: 02e2aef9-fb89-47e5-9f9a-231e533a9e70)
openstack_compute_keypair_v2.keypair: Refreshing state... (ID: terraform-terraform_key)
data.openstack_networking_network_v2.extnet: Refreshing state...
openstack_networking_router_v2.router: Refreshing state... (ID: d79b160f-3755-482a-b700-3ee4aa374ddc)
openstack_networking_subnet_v2.subnet: Refreshing state... (ID: c525dc9b-0b95-4978-9e17-9896f76f1d84)
openstack_networking_port_v2.network_port[0]: Refreshing state... (ID: 66d844bc-bba8-4c26-8e5b-13e0e55b90a9)
openstack_networking_port_v2.network_port[1]: Refreshing state... (ID: 43f1abbd-8cb3-4248-a66d-c14d6177b2aa)
openstack_networking_router_interface_v2.interface: Refreshing state... (ID: 9b11f164-c09e-4319-9298-b5823ad2babb)
openstack_compute_instance_v2.webserver[1]: Refreshing state... (ID: 5b4f822e-a1df-40c6-96b2-1b56a4245de4)
openstack_compute_instance_v2.webserver[0]: Refreshing state... (ID: c473ee3e-0ee2-4114-b982-f5600c3b8a99)
openstack_networking_floatingip_v2.fip[0]: Refreshing state... (ID: 6ae22b26-dd1b-433e-9d35-c75239813c61)
openstack_networking_floatingip_v2.fip[1]: Refreshing state... (ID: 80727eb4-243c-4373-b6c3-3c76b7ef2198)

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create
  ~ update in-place
-/+ destroy and then create replacement

Terraform will perform the following actions:

-/+ openstack_compute_instance_v2.webserver[0] (new resource required)
      id:                            "c473ee3e-0ee2-4114-b982-f5600c3b8a99" => <computed> (forces new resource)
      access_ip_v4:                  "192.168.10.114" => <computed>
      access_ip_v6:                  "" => <computed>
      all_metadata.%:                "0" => <computed>
      availability_zone:             "eu-de-02" => <computed>
      flavor_id:                     "normal1" => <computed>
      flavor_name:                   "s1.medium" => "s1.medium"
      force_delete:                  "false" => "false"
      image_id:                      "4f3d2811-96f2-4706-ac19-3a022fa37281" => <computed>
      image_name:                    "Standard_Debian_9_latest" => "Standard_Debian_9_latest"
      key_pair:                      "terraform-terraform_key" => "terraform-terraform_key"
      name:                          "terraform-webserver01" => "terraform-webserver01"
      network.#:                     "1" => "1"
      network.0.access_network:      "true" => "true"
      network.0.fixed_ip_v4:         "192.168.10.114" => <computed>
      network.0.fixed_ip_v6:         "" => <computed>
      network.0.floating_ip:         "" => <computed>
      network.0.mac:                 "fa:16:3e:75:45:e9" => <computed>
      network.0.name:                "terraform-network" => <computed>
      network.0.port:                "66d844bc-bba8-4c26-8e5b-13e0e55b90a9" => "${element(openstack_networking_port_v2.network_port.*.id, count.index)}" (forces new resource)
      network.0.uuid:                "02e2aef9-fb89-47e5-9f9a-231e533a9e70" => <computed>
      region:                        "" => <computed>
      security_groups.#:             "1" => <computed>
      stop_before_destroy:           "false" => "false"

-/+ openstack_compute_instance_v2.webserver[1] (new resource required)
      id:                            "5b4f822e-a1df-40c6-96b2-1b56a4245de4" => <computed> (forces new resource)
      access_ip_v4:                  "192.168.10.78" => <computed>
      access_ip_v6:                  "" => <computed>
      all_metadata.%:                "0" => <computed>
      availability_zone:             "eu-de-02" => <computed>
      flavor_id:                     "normal1" => <computed>
      flavor_name:                   "s1.medium" => "s1.medium"
      force_delete:                  "false" => "false"
      image_id:                      "4f3d2811-96f2-4706-ac19-3a022fa37281" => <computed>
      image_name:                    "Standard_Debian_9_latest" => "Standard_Debian_9_latest"
      key_pair:                      "terraform-terraform_key" => "terraform-terraform_key"
      name:                          "terraform-webserver02" => "terraform-webserver02"
      network.#:                     "1" => "1"
      network.0.access_network:      "true" => "true"
      network.0.fixed_ip_v4:         "192.168.10.78" => <computed>
      network.0.fixed_ip_v6:         "" => <computed>
      network.0.floating_ip:         "" => <computed>
      network.0.mac:                 "fa:16:3e:f2:cd:5e" => <computed>
      network.0.name:                "terraform-network" => <computed>
      network.0.port:                "43f1abbd-8cb3-4248-a66d-c14d6177b2aa" => "${element(openstack_networking_port_v2.network_port.*.id, count.index)}" (forces new resource)
      network.0.uuid:                "02e2aef9-fb89-47e5-9f9a-231e533a9e70" => <computed>
      region:                        "" => <computed>
      security_groups.#:             "1" => <computed>
      stop_before_destroy:           "false" => "false"

  + openstack_compute_instance_v2.webserver[2]
      id:                            <computed>
      access_ip_v4:                  <computed>
      access_ip_v6:                  <computed>
      all_metadata.%:                <computed>
      availability_zone:             <computed>
      flavor_id:                     <computed>
      flavor_name:                   "s1.medium"
      force_delete:                  "false"
      image_id:                      <computed>
      image_name:                    "Standard_Debian_9_latest"
      key_pair:                      "terraform-terraform_key"
      name:                          "terraform-webserver03"
      network.#:                     "1"
      network.0.access_network:      "true"
      network.0.fixed_ip_v4:         <computed>
      network.0.fixed_ip_v6:         <computed>
      network.0.floating_ip:         <computed>
      network.0.mac:                 <computed>
      network.0.name:                <computed>
      network.0.port:                "${element(openstack_networking_port_v2.network_port.*.id, count.index)}"
      network.0.uuid:                <computed>
      region:                        <computed>
      security_groups.#:             <computed>
      stop_before_destroy:           "false"

  ~ openstack_networking_floatingip_v2.fip[0]
      port_id:                       "66d844bc-bba8-4c26-8e5b-13e0e55b90a9" => "${element(openstack_networking_port_v2.network_port.*.id, count.index)}"

  ~ openstack_networking_floatingip_v2.fip[1]
      port_id:                       "43f1abbd-8cb3-4248-a66d-c14d6177b2aa" => "${element(openstack_networking_port_v2.network_port.*.id, count.index)}"

  + openstack_networking_floatingip_v2.fip[2]
      id:                            <computed>
      address:                       <computed>
      fixed_ip:                      <computed>
      pool:                          "admin_external_net"
      port_id:                       "${element(openstack_networking_port_v2.network_port.*.id, count.index)}"
      region:                        <computed>
      tenant_id:                     <computed>

  + openstack_networking_port_v2.network_port[2]
      id:                            <computed>
      admin_state_up:                "true"
      all_fixed_ips.#:               <computed>
      all_security_group_ids.#:      <computed>
      device_id:                     <computed>
      device_owner:                  <computed>
      fixed_ip.#:                    "1"
      fixed_ip.0.subnet_id:          "c525dc9b-0b95-4978-9e17-9896f76f1d84"
      mac_address:                   <computed>
      network_id:                    "02e2aef9-fb89-47e5-9f9a-231e533a9e70"
      region:                        <computed>
      security_group_ids.#:          "1"
      security_group_ids.2892412908: "77e7d61b-2170-41da-8b7c-bf562b3f904b"
      tenant_id:                     <computed>


Plan: 5 to add, 2 to change, 2 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

openstack_compute_instance_v2.webserver[1]: Destroying... (ID: 5b4f822e-a1df-40c6-96b2-1b56a4245de4)
openstack_compute_instance_v2.webserver[0]: Destroying... (ID: c473ee3e-0ee2-4114-b982-f5600c3b8a99)
openstack_networking_port_v2.network_port[2]: Creating...
  admin_state_up:                "" => "true"
  all_fixed_ips.#:               "" => "<computed>"
  all_security_group_ids.#:      "" => "<computed>"
  device_id:                     "" => "<computed>"
  device_owner:                  "" => "<computed>"
  fixed_ip.#:                    "" => "1"
  fixed_ip.0.subnet_id:          "" => "c525dc9b-0b95-4978-9e17-9896f76f1d84"
  mac_address:                   "" => "<computed>"
  network_id:                    "" => "02e2aef9-fb89-47e5-9f9a-231e533a9e70"
  region:                        "" => "<computed>"
  security_group_ids.#:          "" => "1"
  security_group_ids.2892412908: "" => "77e7d61b-2170-41da-8b7c-bf562b3f904b"
  tenant_id:                     "" => "<computed>"
openstack_networking_port_v2.network_port[2]: Creation complete after 7s (ID: bdb2c226-beca-49c9-8952-50514817062c)
openstack_compute_instance_v2.webserver[2]: Creating...
  access_ip_v4:             "" => "<computed>"
  access_ip_v6:             "" => "<computed>"
  all_metadata.%:           "" => "<computed>"
  availability_zone:        "" => "<computed>"
  flavor_id:                "" => "<computed>"
  flavor_name:              "" => "s1.medium"
  force_delete:             "" => "false"
  image_id:                 "" => "<computed>"
  image_name:               "" => "Standard_Debian_9_latest"
  key_pair:                 "" => "terraform-terraform_key"
  name:                     "" => "terraform-webserver03"
  network.#:                "" => "1"
  network.0.access_network: "" => "true"
  network.0.fixed_ip_v4:    "" => "<computed>"
  network.0.fixed_ip_v6:    "" => "<computed>"
  network.0.floating_ip:    "" => "<computed>"
  network.0.mac:            "" => "<computed>"
  network.0.name:           "" => "<computed>"
  network.0.port:           "" => "bdb2c226-beca-49c9-8952-50514817062c"
  network.0.uuid:           "" => "<computed>"
  region:                   "" => "<computed>"
  security_groups.#:        "" => "<computed>"
  stop_before_destroy:      "" => "false"
openstack_compute_instance_v2.webserver.1: Still destroying... (ID: 5b4f822e-a1df-40c6-96b2-1b56a4245de4, 10s elapsed)
openstack_compute_instance_v2.webserver.0: Still destroying... (ID: c473ee3e-0ee2-4114-b982-f5600c3b8a99, 10s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (10s elapsed)
openstack_compute_instance_v2.webserver.1: Still destroying... (ID: 5b4f822e-a1df-40c6-96b2-1b56a4245de4, 20s elapsed)
openstack_compute_instance_v2.webserver.0: Still destroying... (ID: c473ee3e-0ee2-4114-b982-f5600c3b8a99, 20s elapsed)
openstack_compute_instance_v2.webserver[1]: Destruction complete after 22s
openstack_compute_instance_v2.webserver[1]: Creating...
  access_ip_v4:             "" => "<computed>"
  access_ip_v6:             "" => "<computed>"
  all_metadata.%:           "" => "<computed>"
  availability_zone:        "" => "<computed>"
  flavor_id:                "" => "<computed>"
  flavor_name:              "" => "s1.medium"
  force_delete:             "" => "false"
  image_id:                 "" => "<computed>"
  image_name:               "" => "Standard_Debian_9_latest"
  key_pair:                 "" => "terraform-terraform_key"
  name:                     "" => "terraform-webserver02"
  network.#:                "" => "1"
  network.0.access_network: "" => "true"
  network.0.fixed_ip_v4:    "" => "<computed>"
  network.0.fixed_ip_v6:    "" => "<computed>"
  network.0.floating_ip:    "" => "<computed>"
  network.0.mac:            "" => "<computed>"
  network.0.name:           "" => "<computed>"
  network.0.port:           "" => "43f1abbd-8cb3-4248-a66d-c14d6177b2aa"
  network.0.uuid:           "" => "<computed>"
  region:                   "" => "<computed>"
  security_groups.#:        "" => "<computed>"
  stop_before_destroy:      "" => "false"
openstack_compute_instance_v2.webserver[0]: Destruction complete after 22s
openstack_compute_instance_v2.webserver[0]: Creating...
  access_ip_v4:             "" => "<computed>"
  access_ip_v6:             "" => "<computed>"
  all_metadata.%:           "" => "<computed>"
  availability_zone:        "" => "<computed>"
  flavor_id:                "" => "<computed>"
  flavor_name:              "" => "s1.medium"
  force_delete:             "" => "false"
  image_id:                 "" => "<computed>"
  image_name:               "" => "Standard_Debian_9_latest"
  key_pair:                 "" => "terraform-terraform_key"
  name:                     "" => "terraform-webserver01"
  network.#:                "" => "1"
  network.0.access_network: "" => "true"
  network.0.fixed_ip_v4:    "" => "<computed>"
  network.0.fixed_ip_v6:    "" => "<computed>"
  network.0.floating_ip:    "" => "<computed>"
  network.0.mac:            "" => "<computed>"
  network.0.name:           "" => "<computed>"
  network.0.port:           "" => "66d844bc-bba8-4c26-8e5b-13e0e55b90a9"
  network.0.uuid:           "" => "<computed>"
  region:                   "" => "<computed>"
  security_groups.#:        "" => "<computed>"
  stop_before_destroy:      "" => "false"
openstack_compute_instance_v2.webserver.2: Still creating... (20s elapsed)
openstack_compute_instance_v2.webserver.1: Still creating... (10s elapsed)
openstack_compute_instance_v2.webserver.0: Still creating... (10s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (30s elapsed)
openstack_compute_instance_v2.webserver.1: Still creating... (20s elapsed)
openstack_compute_instance_v2.webserver.0: Still creating... (20s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (40s elapsed)
openstack_compute_instance_v2.webserver.1: Still creating... (30s elapsed)
openstack_compute_instance_v2.webserver.0: Still creating... (30s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (50s elapsed)
openstack_compute_instance_v2.webserver.1: Still creating... (40s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (1m0s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (1m10s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (1m20s elapsed)
openstack_compute_instance_v2.webserver.2: Still creating... (1m30s elapsed)
openstack_compute_instance_v2.webserver[2]: Creation complete after 1m37s (ID: 50d8d14e-e06d-4d9a-9aa8-c3d9ec40c949)

Error: Error applying plan:

2 error(s) occurred:

* openstack_compute_instance_v2.webserver[0]: 1 error(s) occurred:

* openstack_compute_instance_v2.webserver.0: Error trying to get network information from the Network API: Could not find any matching port for port 66d844bc-bba8-4c26-8e5b-13e0e55b90a9
* openstack_compute_instance_v2.webserver[1]: 1 error(s) occurred:

* openstack_compute_instance_v2.webserver.1: Error trying to get network information from the Network API: Could not find any matching port for port 43f1abbd-8cb3-4248-a66d-c14d6177b2aa

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.
@0xErnie
Copy link
Author

0xErnie commented Mar 22, 2018

This problem and a solution is described here:
hashicorp/terraform#14357

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant