Skip to content

Only set policy edge VM host_id when non-empty - #2240

Open
ksamoray wants to merge 1 commit into
vmware:branch_3122from
ksamoray:b3122/fix/2202-edge-vm-host-id
Open

Only set policy edge VM host_id when non-empty#2240
ksamoray wants to merge 1 commit into
vmware:branch_3122from
ksamoray:b3122/fix/2202-edge-vm-host-id

Conversation

@ksamoray

Copy link
Copy Markdown
Contributor

Summary

  • nsxt_policy_edge_transport_node always sent "host_id": "" in the vm_deployment_config payload when host_id was left unconfigured, because getVMDeploymentConfigFromSchema() unconditionally set HostId to a pointer to the (possibly empty) string. NSX then runs its VLAN-segment accessibility validation against an empty host context and creation/update fails with error 16031, even though the same segments work fine when host_id is set explicitly or when deployed via the UI.
  • Guard the assignment the same way compute_folder_id is already guarded, and the same way this was previously fixed for the non-policy nsxt_edge_transport_node resource.
  • Adds a unit test pinning getVMDeploymentConfigFromSchema()'s behavior: host_id must stay unset in the vAPI payload when not configured, and must be set when provided. The existing acceptance test TestAccResourceNsxtPolicyEdgeTransportNode_basic already configures vm_deployment_config without host_id, so it already exercises this path end-to-end and needs no changes.

Note: master's version of this new unit test is gated behind a //go:build unittest tag, but this branch's make test target doesn't pass -tags unittest anywhere, which would make the test silently never run. Dropped the tag here so it runs under the normal go test ./nsxt/ invocation.

Test plan

  • go build ./...
  • go vet ./...
  • gofmt -l . (clean)
  • golangci-lint run ./nsxt/ (0 issues)
  • go test ./nsxt/ -run TestUnitNsxt_getVMDeploymentConfigFromSchema -v — both new tests pass

@ksamoray
ksamoray requested a review from a team August 20, 2026 15:35
@ksamoray

ksamoray commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

/test-all

@ksamoray
ksamoray force-pushed the b3122/fix/2202-edge-vm-host-id branch from 9765f4b to 6dd239f Compare September 3, 2026 09:49
nsxt_policy_edge_transport_node always sent "host_id": "" in the
vm_deployment_config payload when host_id was left unconfigured,
because getVMDeploymentConfigFromSchema() unconditionally set HostId
to a pointer to the (possibly empty) string. NSX then runs its
VLAN-segment accessibility validation against an empty host context
and creation/update fails with error 16031, even though the same
segments work fine when host_id is set explicitly or when deployed
via the UI.

Guard the assignment the same way compute_folder_id is already
guarded, and the same way this was previously fixed for the
non-policy nsxt_edge_transport_node resource.

Add a unit test pinning getVMDeploymentConfigFromSchema()'s behavior:
host_id must stay unset in the vAPI payload when not configured, and
must be set when provided. The existing acceptance test
TestAccResourceNsxtPolicyEdgeTransportNode_basic already configures
vm_deployment_config without host_id, so it already exercises this
path end-to-end and needs no changes.
@ksamoray
ksamoray force-pushed the b3122/fix/2202-edge-vm-host-id branch from 6dd239f to 8c6d8da Compare September 8, 2026 10:47
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