Staged preview refinement for vpc_pair with additional tests - #503
Staged preview refinement for vpc_pair with additional tests#503sivakasi-cisco wants to merge 8 commits into
Conversation
allenrobel
left a comment
There was a problem hiding this comment.
Code review
Two observations on the sync-state refinement — one comment/dead-code cleanup in query.py, one question about the changed promotion in resources.py. The utils.py OperationType.UPDATE fix looks correct (verified register_action_api_call has a single caller, and the per-call Results scoping means no blast radius).
🤖 Generated with Claude Code
|
Just a comment rather than a review comment, but it would be helpful to reviewers if you describe what this PR does in the PR description, along with a description of the changes and why they are needed. |
Hi Allen, True. I moved it from draft to open and had missed it |
|
Could you please confirm whether this is the intended behavior for |
Problem scenarioA vPC pair deletion can be staged using During the staged deletion, the controller removes the pair from the vPC pair inventory before the switch-side removal is saved or deployed. When the module is subsequently invoked with The later invocation therefore returns Steps to reproduce
Controller intent verificationAfter the second module invocation returned Subsequent pendingConfigs:
- no interface port-channel500
- no interface Vlan3600
- no vlan 3600
- no vpc domain 1
- no feature vpc
# plus peer-link member cleanup and interface restoration commandsThis confirms that the staged removal intent was still available to the controller even though the pair was no longer present in the pair inventory. Calling |
|
I noticed that |
|
Impact: Low Problem scenarioA vPC pair can be saved without being deployed using Repeating the identical save-only operation performs another Steps to reproduce
- cisco.nd.nd_manage_vpc_pair:
fabric_name: "<fabric>"
state: merged
config:
- peer1_switch_id: "<peer1>"
peer2_switch_id: "<peer2>"
use_virtual_peer_link: false
config_actions:
save: false
deploy: false
type: switch
- cisco.nd.nd_manage_vpc_pair:
fabric_name: "<fabric>"
state: merged
config:
- peer1_switch_id: "<peer1>"
peer2_switch_id: "<peer2>"
use_virtual_peer_link: false
config_actions:
save: true
deploy: false
type: switch
Observed behaviorThe repeated save-only invocation returns: changed: true
class_diff:
created: []
updated: []
deleted: []
deployment_changed: true
deployment_needed: true
deployment_paths:
- /api/v1/manage/fabrics/<fabric>/actions/configSaveThe API trace for the repeated invocation contains: It contains no vPC-pair Direct The repeated task is therefore reported as |
Hi Nikhil, thank you for the comments. There is one more PR where the config_actions are explictly handled for vpc pair here. Just to avoid repetitive changes, I have handled the default deploy to false in that. |
|
@nikhilsrikrishna , Thank you for the comments. The vPC‑pair module lets to stage a change now and apply it later, but the few bugs made that "do it later" step quietly do nothing - thank you for pointing. "Deploy later" now actually deploys. Before, if we staged a pair (or a deletion) and re‑ran later to push it, the module looked at the controller, decided "nothing to do," reported no change, and left the switches stuck half‑done. Now it notices the still‑pending work and finishes the job. The module now trusts the switches' real status, so it doesn't call something "done" too early. Saving twice no longer lies about changing things. Before, running a save‑only step again and again always said "changed," even when nothing was actually different. Now a repeat save‑only correctly reports no change — which is what automation expect in case of idempotency. Now, the "stage now, apply later" flow for vPC pairs behaves right, it completes pending work, reports change status accurately, and is safe to re‑run |
… deploy_type, negative, staged)
sivakasi-cisco
left a comment
There was a problem hiding this comment.
Comments addressed and tested
|
Thanks, Sivakami, for addressing the earlier comments and explaining the changes. The latest changes address the staged-deletion issue we discussed. However, while reviewing the implementation, I noticed a possible additional edge case when the fabric contains multiple independent vPC pairs. Consider two pairs:
First, A/B is deleted with The deletion of A/B is then invoked again with On this later invocation, elif have:
return _set_lightweight_context(have)This happens without checking whether C/D matches the requested A/B pair and prevents the fallback that reconstructs an already-absent requested pair from being reached. The state machine consequently receives C/D as the existing pair but is asked to delete A/B. Since A/B cannot be found, the operation is recorded as As a result, One possible approach would be for the deleted-state query to use the requested pair identifiers as its source of truth:
The existing Could you please check whether this multi-pair staged-deletion scenario needs to be handled? |
This PR fixes the "stage now, deploy later" flow for vPC pairs.
Before, re-running to deploy a previously staged pair did nothing (changed: false) and left it stuck pending.
Now the module detects pending work on save (not just deploy), trusts the switch's real status over the controller's optimistic summary, and reports changed: true correctly.
Added 4 integration tests in addition (staged ladder, check-mode, deploy-scope, negative).