Skip to content

Fix nsxt_edge_transport_node perpetual drift - #2235

Open
ksamoray wants to merge 1 commit into
vmware:branch_3122from
ksamoray:b3122/fix/3689817
Open

Fix nsxt_edge_transport_node perpetual drift#2235
ksamoray wants to merge 1 commit into
vmware:branch_3122from
ksamoray:b3122/fix/3689817

Conversation

@ksamoray

Copy link
Copy Markdown
Contributor

Summary

  • The NSX MP API returns bare realization UUIDs for uplink_profile, vtep_ha_profile, host_switch_profile and transport_zone, while configuration uses policy paths. This caused a perpetual diff after every apply.
  • NSX also silently injects a default audit_username ("audit") that was not present in configuration, causing a perpetual diff there too.
  • Enforce policy paths via ValidateFunc on uplink_profile, vtep_ha_profile, host_switch_profile elements and transport_zone, making the prior state value for these fields a reliable policy path.
  • In resourceNsxtEdgeTransportNodeRead, capture the prior state before setHostSwitchSpecInSchema overwrites it with API UUIDs, then restore any policy-path values via etNodeNormalizeHostSwitchesInState.
  • Mark audit_username as Optional+Computed so Terraform accepts the NSX default value without showing a diff when the user omits the field.

This is a hand-port of the equivalent fix on master, adapted for this release branch (master's version also reverts an unported earlier fix attempt; this PR implements the final, corrected behavior directly against branch_3122's current schema).

Test plan

  • go build ./...
  • go vet ./...
  • gofmt -l . (clean)
  • golangci-lint run ./nsxt/ (0 issues)

No acceptance/unit test coverage is added, matching the corresponding fix on master, which also shipped without one.

@ksamoray
ksamoray requested a review from a team August 20, 2026 10:12
@ksamoray

Copy link
Copy Markdown
Contributor Author

/test-all

@ksamoray

ksamoray commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

/test-all

The NSX MP API returns bare realization UUIDs for uplink_profile,
vtep_ha_profile, host_switch_profile and transport_zone, while
configuration uses policy paths. This caused a perpetual diff after
every apply. Additionally, NSX silently injects a default
audit_username ("audit") that was not present in configuration.

Fix strategy:
- Enforce policy paths via ValidateFunc on uplink_profile,
  vtep_ha_profile, host_switch_profile elements and transport_zone.
  This makes the prior state value for these fields a reliable
  policy path.
- In resourceNsxtEdgeTransportNodeRead, capture the prior state
  before setHostSwitchSpecInSchema overwrites it with API UUIDs,
  then restore any policy-path values via
  etNodeNormalizeHostSwitchesInState. Because inputs are validated
  to be policy paths no API lookup is needed: isPolicyPath(priorVal)
  is sufficient to decide what to keep.
- Mark audit_username as Optional+Computed so Terraform accepts the
  NSX default value without showing a diff when the user omits the
  field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant