nd_interface_port_channel_*: member-already-in-use preflight - #548
Open
allenrobel wants to merge 1 commit into
Open
nd_interface_port_channel_*: member-already-in-use preflight#548allenrobel wants to merge 1 commit into
allenrobel wants to merge 1 commit into
Conversation
allenrobel
requested review from
akinross,
anvitha-jain,
gmicol,
lhercot,
mikewiebe,
mtarking,
sajagana,
samiib and
shrsr
as code owners
September 2, 2026 00:40
Reject, before any write, a port-channel whose member ethernet is already
owned by a different port-channel. ND 4.2.1 rejects this at create with a
flat HTTP 500 {code, message} envelope (vault:
port-channel-member-conflict-returns-500) that surfaced mid-run as
"Create failed for <po>"; the module now fails fast with a validation
error naming each member and its current owner, in check mode too.
- PortChannelBaseOrchestrator.query_all reads the per-switch inventory
through the shared _switch_interfaces cache (no behavior change), so
the preflight reads the unfiltered records the state machine's initial
query_all already fetched: zero extra requests.
- preflight() override: capability preflight, then
_validate_members_available. Owners come from every portChannel
record's `ports` list regardless of policy type (a vpcPeerlinkPo owner
is still a conflict), with a *Member policyType fallback for members
no port-channel record lists. Same-PO ownership passes (idempotent
re-apply); two proposed port-channels claiming the same member on one
switch also fail.
- Module docs note the behavior; changelog fragment added.
- Unit tests: access 00900-00970 (free / cross-PO / cross-type /
idempotent / check mode / intra-task duplicate / no extra request /
orphan *Member), trunk_host 00900-00910.
Closes #369
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012LpZPyFp9vCBb1mH97CXj4
allenrobel
force-pushed
the
nd_interface_port_channel_member_preflight
branch
from
September 2, 2026 17:19
eec96e8 to
740089d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related Issue(s)
Closes #369
Proposed Changes
Add a client-side member-already-in-use preflight to the port-channel orchestrators (
nd_interface_port_channel_access,nd_interface_port_channel_trunk_host), per the design agreed in #369.ND 4.2.1 rejects a port-channel create whose
portsmember already belongs to another port-channel with a flat HTTP 500{code, message}envelope (noresults[]) -- a permanent 409-class conflict dressed as a server error (vault:port-channel-member-conflict-returns-500). Today that surfaces mid-run asCreate failed for <po>: ..., after any earlier interfaces in the same POST batch were already accepted. The module now fails fast with a validation error naming each offending member and its current owner, before any write, in check mode too.PortChannelBaseOrchestrator.query_allnow reads each switch's inventory through the sharedNDBaseInterfaceOrchestrator._switch_interfacescache (mirroring the ethernet/loopback/SVI orchestrators). No behavior change; it was the last orchestrator still issuing its own per-switch_request. This warms the cache with the unfiltered records during the state machine's initialquery_all.PortChannelBaseOrchestrator.preflightoverride: runs the inherited capability preflight, then_validate_members_available. Because it reads the same cache, it issues zero additional requests for merged/replaced/overridden.portChannelrecord'sportslist regardless of policy type, so a member of an unmanaged flavor (e.g.Ethernet1/2owned byport-channel500/vpcPeerlinkPo) is still a conflict -- the filteredbeforeview would miss it.operData.portChannelId(which stays-1until the owner is deployed; ND still rejects the conflict).policyTypeends inMemberbut that no port-channel record lists is treated as owned (owner reported as unknown) rather than free.--checkmode: unlike the capability preflight (unpublished endpoint), this data comes from the standard interfaces GET.TODO(4.2.1) port-channel-member-conflict-returns-500.descriptiongets one line stating the fail-fast behavior; changelog fragment added.interface_type/interface_modeClassVars for port-channels.Test Notes
tests/unit/module_utils/orchestrators/test_port_channel_access_interface.py(00900-00970): free member passes; cross-PO conflict aggregates every offender naming member + owner; cross-type (vpcPeerlinkPo) owner conflicts; same-PO re-apply passes (case-insensitive); check mode still fails; intra-task duplicate claim fails;query_allthenpreflightconsumes no extra response (generator exhaustion would raise) and the cache retains the unfiltered inventory; orphan*Memberpolicy type fails.test_port_channel_trunk_host_interface.py00900-00910 confirm inheritance.ndpytest tests/unit/).ndtest --test pylint/--test validate-moduleson the changed plugin files pass;ndblack,ndisortclean;ndmypyerror count onport_channel_base.pyunchanged from develop (pre-existingNDBaseModelattr-defined pattern noted at the top of the file).Cisco Nexus Dashboard Version
4.2.1
Related ND API Resource Category
Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_012LpZPyFp9vCBb1mH97CXj4