Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple resource pools issue when fetching VM Groups #530

Merged
merged 13 commits into from
Dec 7, 2022

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Dec 1, 2022

Context

In v2.17.0, more specifically in #504, we introduced the ability to fetch VM Groups from VCD. However, these methods were failing when the Provider VDC had more than one resource pool.

RCA

The buggy functions are GetVmGroupByNamedVmGroupIdAndProviderVdcUrn and GetVmGroupByNameAndProviderVdcUrn. They use a private function called getResourcePools which is the culprit. This function is wrongly assuming that there can be only a single resource pool per Provider VDC.

Fix

This PR changes:

  • getResourcePools doesn't return error if there is more than one resource pool, as this the natural way of working: A Provider VDC can have multiple Resource pools.
  • When multiple resource pools are found, the filter to search a VM Group just considers all of them (by constructing a filter using logical OR forms) like UI does. For example: filter=(vmGroupName==testVmGroup;(clusterMoref==domain-c12,clusterMoref==domain-c12);(vcId==f583b76e-9e34-48e7-b90d-930653ee1616,vcId==f583b76e-9e34-48e7-b90d-930653ee1616))
  • This relies in the fact that one can't have multiple VM Groups in vSphere with same name on different resource pools.

Test

To test this, one can create more Resource Pools in the vSphere that serves VCD. In the following image, we have foo and STFTestRootResourcePool:
Screenshot 2022-12-01 at 15 36 56

Once the Resource Pool is created, one can place some VMs there and create a VM Group there. In the following image, we have a VM Group called foo1 with ldap-server VM (in STFTestRootResourcePool resource pool) and VM Group asd with saddasd VM (in foo resource pool)
Screenshot 2022-12-01 at 15 37 05
Screenshot 2022-12-01 at 15 37 10

Ideally, we should have something like the above: some VM Groups locating VMs to different VMs served by different Resource Pools.

After we have some VM Groups, we can configure the target Provider VDC to add the new Resource pool:
Screenshot 2022-12-01 at 15 37 22

Test Test_VmGroupsCRUD should pass with this patch and this configuration. Without this fix, it should fail with the error

could not get VM Group: more than one Resource Pool found for the pVDC

Signed-off-by: abarreiro <[email protected]>
@adambarreiro adambarreiro self-assigned this Dec 1, 2022
Signed-off-by: abarreiro <[email protected]>
@adambarreiro adambarreiro marked this pull request as ready for review December 1, 2022 14:46
#
Signed-off-by: abarreiro <[email protected]>
abarreiro added 6 commits December 2, 2022 10:10
Signed-off-by: abarreiro <[email protected]>
#
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
Signed-off-by: abarreiro <[email protected]>
@Didainius Didainius merged commit 31e9ce0 into vmware:main Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants