Repository navigation
fix(neutron-understack): lift vlan trunk restrictions (no. 2) - #2468
Conversation
Python test results2 537 tests 2 532 ✅ 2m 3s ⏱️ Results for commit 3aa830e. ♻️ This comment has been updated with latest results. |
3f2c49a to
1e28e5f
Compare
b7bdc29 to
8ad39e7
Compare
|
I'll rebase this before reviewing. |
8ad39e7 to
72c91c7
Compare
| if not utils.parent_port_is_bound(parent_port): | ||
| return | ||
|
|
||
| physical_network = parent_port.bindings[0].profile.get("physical_network") |
There was a problem hiding this comment.
This needs to use the active port binding
| if not physical_network: | ||
| # The create path reports the more specific missing-physnet error | ||
| # when it attempts to configure the parent switchport. | ||
| return |
There was a problem hiding this comment.
If this is already handled in the parent then let's do it there?
| ) | ||
|
|
||
| if not utils.parent_port_is_bound(parent_port): | ||
| return |
There was a problem hiding this comment.
Given this check is done in the caller immediately after this function. Would it make more sense to split up the check to just have the above for loop before that check and then the rest of this function below.
| trunk_details: dict, | ||
| physical_network: str, | ||
| native_vlan_id: int, | ||
| ) -> None: |
There was a problem hiding this comment.
Rather than this extra function as indirection, can we just add the check into configure_trunk() and call the function?
The check was added to prevent the user from claiming a segmentation ID that happens to be the same as the parent port of this vlan. We don't want to allow that situation because the switch (stupidly) rejects that configuration. However, the way the check was implemented was too restrictive - it banned a range of thousands of VLAN IDs. It did successfully prevent all theoretical clashes present and future, but it also prevented legitimate configurations and caused an upset customer. We update this check so that it now compares the VLAN ID of the actual native VLAN on this trunk interface, and only raises an error if the user is configuring a number that would currently clash. The theoretical valid range is 1-4094 according to 802.1Q. However we would avoid VLAN 1, and we must avoid our nxos "reserved" vlan range 3872-3999. On Nexus 9000 NX-OS, Cisco treats VLANs 4048-4093 as their own. These might work, but even if they work today, they might randomly stop working at some future point. So this puts the realistic useable VLAN range at 2-3871 inclusive.
Avoid VLANs that may be reserved/used by Cisco for their own purposes.
The native VLAN is only known once the dynamic segment has been allocated, so on a first bind the subport collision check in configure_trunk() can only run afterwards. If it raised, the freshly allocated segment was left on the network. ML2 swallows exceptions from bind_port, so nothing gave it back until the port was deleted, and every retry reused it and failed the same way. Release the segment on failure, but only if this bind allocated it and no other port is bound to it. A segment that already existed is not ours to release.
The parent port is not allowed to be updated after the trunk has been created so this extra check will never catch any problems.
Cover the case where a parent port, its trunk and all subports are created before the parent is bound. Subport adds are no-ops while the parent has no physical network, so configure_trunk() has to allocate the subport segments and binding levels when the parent later binds. Also mark the existing native VLAN collision scenario as a strict xfail. The collision is detected in bind_port, but ML2 cannot abort a bind: it falls through to the next mechanism driver and the port still binds (vif_type=other) rather than binding_failed. This needs the upstream Neutron fix backported.
main exempted a subport tagged with its own network's fabric_vlan from the old "outside every shared segment range" check. Replacing that check with default_tenant_vlan_id_range dropped the exemption, so carry it over: the Palo Alto wiring tags router subports with the network's fabric_vlan and relies on the trunk driver accepting it even if the fabric range lies outside the tenant range. The old "any other VLAN in the fabric range is rejected" behaviour was a side effect of the blanket segment-range ban that this branch removes, so SVLAN-09 now accepts such a tag unless it collides with the parent's native VLAN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ound configure_trunk() runs on every bind of a trunk parent port, and this branch made it call utils.fetch_network_node_trunk_id() up front to decide whether to skip the native/tagged VLAN collision check. That lookup is not cheap and is not safe to call unconditionally: * it raises a bare Exception if there is no alive OVN Controller Gateway agent, if Ironic cannot resolve the gateway host, or if the network-node trunk has not been created yet; * only a successful result is cached, so every failing bind repeats the agent query, the Ironic call and the trunk scan. Before this branch the bind path never made the call, so any of those conditions would newly turn a healthy trunk parent bind into binding_failed - including trunks with no subports at all, and plausibly the network node's own trunk parent while it is first being provisioned and its gateway agent is not yet running. Move the network-node exemption into _check_native_vlan_conflict() and consult it only after a subport tag actually equals the native VLAN. A trunk with no subports, or whose tags don't collide, never makes the lookup. The network-node trunk can't produce a collision in practice (its tags are the subports' own segment VLANs, allocated from the same physnet as the native segment), so in normal operation the lookup is now never reached from the bind path. This also removes the duplicate early return in _check_subports_segmentation_id(), so the exemption is decided in one place for both the bind and subport-add paths. The subport-add path still calls the lookup from _assert_segmentation_id_in_range(), as it did before this branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_check_subports_segmentation_id() no longer validates tenant tags against a range; it only rejects a collision with the parent's native VLAN. utils.is_network_fabric_vlan() referred to the removed allowed_tenant_vlan_id_ranges() check in the trunk driver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a trunk parent binds, configure_trunk() walks the subports and, for each one, allocates (or reuses) a dynamic segment on the parent's physnet and writes a level-0 binding row for the subport on the parent's host. If that fails part-way - a DB error, or VlanIdInUse requesting a subport network's fabric_vlan - the except block in _bind_port_segment() only released the parent's native segment. Subports configured before the failure kept their binding rows and dynamic segments, and nothing would ever clean them up: the parent is binding_failed, so clean_trunk() never runs on unbind. Call trunk_driver.clean_trunk() for the parent's host from the except block before releasing the native segment. clean_trunk() deletes each subport's binding level on that host and releases its segment only if no other port is bound to it. On a native VLAN collision nothing has been created yet, so it is a no-op. The cleanup must never mask the error that failed the binding: if a cleanup step itself raised, that exception would propagate in place of the original and ML2 would report the wrong cause. Each step now lives in its own helper that logs and suppresses its own failure, so the bare `raise` always re-raises the original exception. Tests cover both cleanup steps raising. ML2 calls bind_port outside any DB transaction, so the cleanup holds no locks from the surrounding request; each step commits its own short write transaction exactly as the allocation path already does. Lock contention with another request surfaces as a DBDeadlock exception (logged and suppressed), not a hang. Scenario TRUNK-PARENT-BIND-PARTIAL-01 drives this through real ML2 and fails without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a120372 to
3aa830e
Compare
Trunk subport VLAN tags used to be rejected if they fell in any shared VLAN segment range, which blocked thousands of valid IDs. This PR replaces that rule with two checks:
A collision found while binding now raises PortBindingError, so the port ends up binding_failed. The VLAN segments and subport binding rows created during that bind are cleaned up. A subport tagged with its own network's fabric_vlan is still accepted.
The new range default also changes which VLANs the Palo Alto router wiring can pick.