Only set policy edge VM host_id when non-empty - #2240
Open
ksamoray wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
/test-all |
ksamoray
force-pushed
the
b3122/fix/2202-edge-vm-host-id
branch
from
September 3, 2026 09:49
9765f4b to
6dd239f
Compare
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
force-pushed
the
b3122/fix/2202-edge-vm-host-id
branch
from
September 8, 2026 10:47
6dd239f to
8c6d8da
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.
Summary
nsxt_policy_edge_transport_nodealways sent"host_id": ""in thevm_deployment_configpayload whenhost_idwas left unconfigured, becausegetVMDeploymentConfigFromSchema()unconditionally setHostIdto 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 whenhost_idis set explicitly or when deployed via the UI.compute_folder_idis already guarded, and the same way this was previously fixed for the non-policynsxt_edge_transport_noderesource.getVMDeploymentConfigFromSchema()'s behavior:host_idmust stay unset in the vAPI payload when not configured, and must be set when provided. The existing acceptance testTestAccResourceNsxtPolicyEdgeTransportNode_basicalready configuresvm_deployment_configwithouthost_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 unittesttag, but this branch'smake testtarget doesn't pass-tags unittestanywhere, which would make the test silently never run. Dropped the tag here so it runs under the normalgo 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