Skip to content

fix: allow multiple subnet for fd in a RP - #788

Merged
abhay-nutanix merged 1 commit into
mainfrom
issue/recoveryPlan
Sep 25, 2026
Merged

abhay-nutanix merged 1 commit into
mainfrom
issue/recoveryPlan

Conversation

@abhay-nutanix

@abhay-nutanix abhay-nutanix commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

The vHA domain recovery-plan generation previously supported only a single subnet per failure domain (it used fd.Spec.Subnets[0] and ignored the rest) and required both metro failure domains to be paired strictly by list position. This PR generalizes the network mapping to support multiple subnets per failure domain, and pairs the two failure domains' subnets by their L2 network identity (network layer, VLAN ID/VNI, CIDR) rather than by list position.

Motivation
A metro spans two Prism Elements, each with its own Prism subnet objects (distinct names/UUIDs) that represent the same underlying L2 networks. Real deployments frequently have more than one subnet per site, and the two sites may:

  • list their subnets in a different order, and/or
  • list a different number of subnets (e.g. an extra site-local subnet with no metro peer).

The old logic could not represent multi-subnet configs and would mispair or reject these valid setups.

What changed

  • Multiple subnets per FD in one recovery plan. New helper vhaRecoveryPlanNetworkMappings builds one NetworkMappingList entry per subnet pair, so every paired FD subnet is included in the same recovery plan (subnet j of PE 0 ↔ subnet j of PE 1). subnetNames changed from []string to [][]string and getOrCreateVHADomainRecoveryPlan now delegates the mapping construction to this helper.
  • Pair by L2 network, not list position. New helper pairVHADomainSubnetsByL2 resolves each FD's subnets to their L2 network key (via the existing subnetNetworkKeys) and matches subnets across the two FDs by that key. Each peer subnet is consumed at most once, so duplicate L2 networks pair one-to-one. The returned slices are positionally aligned to the metro's failure-domain order.
  • Ignore unpaired subnets. If FD-A lists 2 subnets and FD-B lists 3, only the subnets sharing an L2 network are mapped; the extra unpaired subnet is dropped. The two failure domains no longer need the same subnet count. A warning log is emitted for each dropped subnet (with FD name, subnet identifier, and L2 key).
  • Fail fast when there is no common network. If the two FDs share no L2 network at all, reconciliation errors out, since a metro recovery plan needs at least one network to map between the PEs. This check runs before the "already ready" short-circuit, so a metro whose subnets drift apart fails reconciliation even after the vHA domain was marked ready.
  • Replaced the previous validateVHADomainFailureDomainSubnets (equal-count + index-aligned validation) with the pairing logic above.

@abhay-nutanix abhay-nutanix changed the title Issue/recovery plan fix: allow multiple subnet for fd in a RP Sep 21, 2026
@abhay-nutanix
abhay-nutanix marked this pull request as draft September 21, 2026 11:17
@abhay-nutanix
abhay-nutanix marked this pull request as ready for review September 25, 2026 06:40
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.07595% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.20%. Comparing base (883f3c9) to head (c4ca38c).
⚠️ Report is 129 commits behind head on main.

Files with missing lines Patch % Lines
controllers/nutanixvirtualhadomain_controller.go 86.07% 8 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #788       +/-   ##
===========================================
+ Coverage   43.96%   54.20%   +10.24%     
===========================================
  Files          18       32       +14     
  Lines        2593     6261     +3668     
===========================================
+ Hits         1140     3394     +2254     
- Misses       1417     2550     +1133     
- Partials       36      317      +281     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@abhay-nutanix
abhay-nutanix merged commit a1637c6 into main Sep 25, 2026
37 checks passed
@abhay-nutanix
abhay-nutanix deleted the issue/recoveryPlan branch September 25, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants