Skip to content

Commit

Permalink
order realized VM results by external_id
Browse files Browse the repository at this point in the history
This PR adds external_id as the sortByParam for calls to the realized VM
endpoint. This is needed in larger environments (1k+ VMs) because as of
NSX-T 3.2.3 the /policy/api/v1/infra/realized-state/virtual-machines
endpoint is not respecting a consistent ordering by default. This means
that the internal slice representing VMs returned from
listAllPolicyVirtualMachines may include duplicates and may be missing
VMs that actually exist. Explicitly setting an order forces consistent
results across the paginated calls.

Resolves: #1193
Signed-off-by: Paul Zerkel <zerkel@gmail.com>
  • Loading branch information
paulzerkel committed Apr 22, 2024
1 parent 4eb43a0 commit f54e7a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nsxt/resource_nsxt_policy_vm_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ func listAllPolicyVirtualMachines(context utl.SessionContext, connector client.C
// NOTE: Contrary to the spec, this API does not populate cursor and result count
// parameters, respects cursor input. Therefore we determine end of VM list by
// looking for empty result.
vms, err := client.List(cursor, nil, &boolFalse, nil, nil, &boolFalse, nil)
sortBy := "external_id"
vms, err := client.List(cursor, nil, &boolFalse, nil, nil, &boolFalse, &sortBy)
if err != nil {
return results, err
}
Expand Down

0 comments on commit f54e7a2

Please sign in to comment.