vmware / go-vcloud-director

Golang SDK for VMware Cloud Director
Other
80 stars 76 forks source link

GetNetworkList() truncates the network list when a VDC has more than 25 networks #514

Closed RussPitcher closed 1 year ago

RussPitcher commented 2 years ago

Describe the bug

When running a Terraform action against an OrgVDC with more than 25 OrgVDC networks the state refresh fails with one or more errors as follows:

Error: error retrieving network myOrgVdcNetwork from network list

On investigation we discovered that the query used to retrieve the network list does not manage paged responses and therefore uses the default page size of 25 records. Any records apart from the initial 25 are not returned. This causes the calling functions to fail when the expected network is missing.

We tracked the REST call down to the GetNetworkList() function in the orgvdcnetwork.go file and it can be seen that the pageSize parameter is not used, and the function itself does not attempt to handle paged responses.

Reproduction steps

  1. Create an OrgVDC with more than 25 terraform-managed vdc_network_direct objects
  2. Run a terraform plan

Expected behavior

The terraform plan should refresh the state successfully without errors

Additional context

Adding a simple "pageSize": "128" to the query would reduce the scope of this issue (as has been done in the QueryProviderVdcStorageProfileByName function) but it would be better to implement proper support for paged responses.

dataclouder commented 2 years ago

Thanks for the investigation. we were aware of the problem, but this function skipped through the cracks last time we went around fixing it. There is a simple fix (we do have a cumulativeQuery that does the pagination automatically). It will require some tests, but it should be addressed easily.

dataclouder commented 1 year ago

Fixed with PR #518