summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-04-14 11:22:12 +0000
committerGerrit Code Review <review@openstack.org>2021-04-14 11:22:12 +0000
commitb31c8a8b1abce7a156f374f45caa83c610f9d3e2 (patch)
treeb74fff9d3566ee1fde568cf115821986e4f365d4
parent8bdf6b984a457301b43fdecf0dc27e667bcfc910 (diff)
parent546bc2391511fab3f2d8e0474f7aa1b6a0cde708 (diff)
downloadheat-b31c8a8b1abce7a156f374f45caa83c610f9d3e2.tar.gz
Merge "Net attr: Sort segments without name attribute first" into stable/victoria
-rw-r--r--heat/engine/resources/openstack/neutron/net.py7
-rw-r--r--releasenotes/notes/os-neutron-net-segments-attribute-semi-predictable-b40a869317d053cc.yaml16
2 files changed, 22 insertions, 1 deletions
diff --git a/heat/engine/resources/openstack/neutron/net.py b/heat/engine/resources/openstack/neutron/net.py
index 62a19e1ff..d0d2ebd8d 100644
--- a/heat/engine/resources/openstack/neutron/net.py
+++ b/heat/engine/resources/openstack/neutron/net.py
@@ -284,8 +284,13 @@ class Net(neutron.NeutronResource):
if self.resource_id is None:
return
if name == self.SEGMENTS:
- return [segment.to_dict() for segment in list(self.client(
+ segments = [segment.to_dict() for segment in list(self.client(
'openstack').network.segments(network_id=self.resource_id))]
+ # Sort segments without name attribute first.
+ # See bug: https://bugs.launchpad.net/tripleo/+bug/1894920
+ segments.sort(key=lambda s: s['name'] is not None)
+ return segments
+
attributes = self._show_resource()
return attributes[name]
diff --git a/releasenotes/notes/os-neutron-net-segments-attribute-semi-predictable-b40a869317d053cc.yaml b/releasenotes/notes/os-neutron-net-segments-attribute-semi-predictable-b40a869317d053cc.yaml
new file mode 100644
index 000000000..f398d8928
--- /dev/null
+++ b/releasenotes/notes/os-neutron-net-segments-attribute-semi-predictable-b40a869317d053cc.yaml
@@ -0,0 +1,16 @@
+---
+fixes:
+ - |
+ The ordering in the list of segments returned by ``OS::Neutron::Net``
+ resources is not predictable. Stack updates changeing attributes
+ of the network can cause the list of segments to shift.
+
+ The ordering is now slightly more predictable, segments with name=``None``
+ are now placed first in the list. This doesn't guarantee the order, but
+ typically only the segment implicitly created by neutron has no name
+ attribute set. The template author should ensure other segments on the
+ network does have a name set, so that the implicit segment will always be
+ index 0. Resolving attributes of the implcitly created segment on the
+ network resource can then predictibly happen using index 0. See `bug:
+ 1894920 <https://bugs.launchpad.net/tripleo/+bug/1894920>`_.
+