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_networking_port_v2 allowed_address_pairs are sorted #9680

Closed
carlpett opened this issue Oct 28, 2016 · 1 comment · Fixed by #10250
Closed

openstack_networking_port_v2 allowed_address_pairs are sorted #9680

carlpett opened this issue Oct 28, 2016 · 1 comment · Fixed by #10250
Labels

Comments

@carlpett
Copy link
Contributor

The allowed_address_pairs property is ordered by creation time in the state file, but the Gophercloud api returns them sorted, rather than the order which they were inserted. If they were not created in sorted order, Terraform wants to apply a change of order in every execution (since the output does not actually change after apply)

Terraform Version

Terraform v0.7.3

Affected Resource(s)

  • openstack_networking_port_v2

Terraform Configuration Files

resource "openstack_networking_port_v2" "vrrp-ports" {
  count = 3
  name = "${var.vrrp-names[count.index]}"
  network_id = "${var.network_id}"
  admin_state_up = "true"
  fixed_ip {
    subnet_id = "${var.subnet_id}"
  }
}
resource "openstack_networking_port_v2" "instance-ports" {
  count = 2
  name = "instance-port-${count.index+1}"
  network_id = "${var.network_id}"
  admin_state_up = "true"
  fixed_ip {
    subnet_id = "${var.subnet_id}"
  }
  allowed_address_pairs {
    ip_address = "${openstack_networking_port_v2.my-ports.0.fixed_ip.0.ip_address}"
  }
  allowed_address_pairs {
    ip_address = "${openstack_networking_port_v2.my-ports.1.fixed_ip.0.ip_address}"
  }
  allowed_address_pairs {
    ip_address = "${openstack_networking_port_v2.my-ports.2.fixed_ip.0.ip_address}"
  }
}

Steps to Reproduce

If vrrp-ports gets addresses in a different ordering compared with their index in the state file, every apply will try to change the order of allowed_address_pairs:

  1. terraform apply
openstack_networking_port_v2.instance-ports.1: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"
openstack_networking_port_v2.instance-ports.0: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"
  1. terraform apply
openstack_networking_port_v2.instance-ports.1: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"
openstack_networking_port_v2.instance-ports.0: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"
  1. terraform apply
openstack_networking_port_v2.instance-ports.1: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"
openstack_networking_port_v2.instance-ports.0: Modifying...
  allowed_address_pairs.1.ip_address: "10.36.8.4" => "10.36.8.5"
  allowed_address_pairs.2.ip_address: "10.36.8.5" => "10.36.8.4"

The cause is that ports ip addresses are out of order:

$ terraform state show openstack_networking_port_v2.vrrp-ports[0]
[...]
fixed_ip.#              = 1
fixed_ip.0.ip_address   = 10.36.8.3
[...]

$ terraform state show openstack_networking_port_v2.vrrp-ports[1]
[...]
fixed_ip.#              = 1
fixed_ip.0.ip_address   = 10.36.8.5
[...]

$ terraform state show openstack_networking_port_v2.vrrp-ports[2]
[...]
fixed_ip.#              = 1
fixed_ip.0.ip_address   = 10.36.8.4
[...]

Could the allowed_address_pairs be stored in an unordered structure? Otherwise I guess it will require a bit more complicated logic for determining changes.

@ghost
Copy link

ghost commented Apr 19, 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 19, 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