provider/openstack: Resolve issues with Port Fixed IPs #13056
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit has two parts:
It adds a new computed-only attribute called
all_fixed_ips
which contain all of the fixed IPs returned by the OpenStack Networking API in the order the API sent them.It changes the
fixed_ip
attribute back to a TypeList, reverting the change made in provider/openstack: Change Port fixed_ip to a Set #12613. The change made in provider/openstack: Change Port fixed_ip to a Set #12613 resolved the reported issue, but created other state issues in different use-cases.Fixes #13052
Supersedes #12807
@stack72 Let me know if you would like to discuss this one in more detail.
I'm pretty sure moving from
TypeSet
toTypeList
is safe to do, but maybe I am wrong about that.The main change being made (making
fixed_ip
non-compute) will affect users who were relying on referencing a DHCP-allocated IP byopenstack_networking_port_v2.foo.fixed_ip.0.ip_address
. They will now need to useopenstack_networking_port_v2.foo.all_fixed_ips.0
. This should probably be noted in the CHANGELOG.Users who specified a static IP can return to referencing
openstack_networking_port_v2.foo.fixed_ip.0.ip_address
as they did before, since it's not relying on a returned API value. The most notable reason for doing this is to make implicit ordering between resources.Users who reported issues with
fixed_ip
being re-ordered upon arefresh
are still in the clear sincefixed_ip
is no longer being set by Terraform.Unless I'm mistaken, with the list of scenarios in #13052, there are just too many varied cases that can be cleanly applied in
fixed_ip
alone. Notably, creating a unique hash withTypeSet
is not possible when a user wants multiple DHCP-based Fixed IPs since the only required piece of data is asubnet_id
, and if there are multiple entries with the samesubnet_id
, Terraform will hash them all the same and aggregate them into 1 requested IP. Further, ifip_address
is also used in the hash, then DHCP IPs will have a new generated hash afterapply
finishes. Therefore, something likeall_fixed_ips
is needed.Perhaps a better long-term design is to create a dedicated
openstack_networking_port_fixedip_v2
resource and deprecate the use offixed_ip
andall_fixed_ips
, but, again, the multiple-DHCP use-case is probably going to make that difficult./cc @sebastien-prudhomme