VMware Cloud Community
Stephon_Chen
Contributor
Contributor

[Bug] Listing resources through API returns different results with / without paging

Hello all,

I am wondering that listing resources through API returns different results with / without paging.

Setup is as the following:

  • vRA version: 7.3
  • VM counts in the tenant: 99
  • Steps
    • Without paging (limit = 999)

curl -s --data-urlencode "orderby=name asc&filter=(resourceType/id eq 'Infrastructure.Virtual' and organization/subTenant/name eq '${TENANT_NAME}' and outputResourceType/name eq 'VirtualMachine')" -k -X GET "https://${VRA_HOST}/catalog-service/api/consumer/resources?limit=999" -H 'Accept: application/json' -H "Authorization: Bearer ${VRA_TOKEN}"

      • Output VM count: 99
    • With paging

for i in `seq 1 3`; do

            curl -s --data-urlencode "orderby=name asc&filter=(resourceType/id eq 'Infrastructure.Virtual' and organization/subTenant/name eq '${TENANT_NAME}' and outputResourceType/name eq 'VirtualMachine' and catalogItemType/name eq 'VirtualMachine')" -k -X GET "https://${VRA_HOST}/catalog-service/api/consumer/resources?limit=${LIMIT}&page=${i}" -H 'Accept: application/json'  -H "Authorization: Bearer ${VRA_TOKEN}"

    • While
      • limit = 40, VM counts: 61
      • limit = 50, VM counts: 73
      • limit = 60, VM counts: 91
      • limit = 70, VM counts: 99 (correct)

Even if referring to bug in pagination at path "/catalog-service/api/consumer/resources?limit=20" duplicate machines retu...

Order by has no effect, as sample testing command above mentioned.

From my perspective, I want to fetch VM counts in parallel way to speed up.

What's the better way to achieve this goal?

Thanks a lot.

Tags (3)
1 Reply
StefanSchnell
Enthusiast
Enthusiast

These days I had a similar problem as described by @Stephon_Chen. I wanted to get details of VMs, of the type Cloud.vSphere.Machine, with the API call deployment/api/resources. In some tests I always got double entries of VMs back, in different vRA 8.10.2 environments. The number of VMs returned was always identical, but the content differed. Most of the time it was correct and sometimes one VM was duplicated and another was missing. Therefore I set the query option size, just like the Orchestrator does, and the behavior no longer occurred.


More interesting information at blog.stschnell.de

Reply
0 Kudos