Enhance the listAffinityGroups API by adding the dedicated resources related to an affinity group#9188
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9188 +/- ##
============================================
- Coverage 15.54% 15.54% -0.01%
- Complexity 11996 11998 +2
============================================
Files 5499 5501 +2
Lines 481706 481751 +45
Branches 62623 59402 -3221
============================================
+ Hits 74884 74886 +2
- Misses 398536 398578 +42
- Partials 8286 8287 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
d898442 to
a35a0e6
Compare
|
@bernardodemarco , I have no time to review now, but did go through your test cases and am wondering about one scenario:
|
|
@DaanHoogland, I'm not entirely sure I understand the scenario you proposed. However, here are some more detailed test cases that I believe could fit the proposed scenario. Test CasesEnvironment
|
|
ok @bernardodemarco , this means that listing will show the dedicated resources, even if the caller has no access to them, right? |
Actually, in the provided test cases on #9188 (comment), the Here are some test cases, in the same environment as the previous tests, calling the I created a user with the User role, called
|
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm (i think there is something to be gained in refactorring the dedicate<Zone|Pod|Cluster|Host>() methods, but that is out of scope here.
lucas-a-martins
left a comment
There was a problem hiding this comment.
LGTM
In a local environment, I conducted the following tests:
Using a ROOT Admin, I dedicated a zone called zn-acs to the domain ROOT and admin account.
Using the listAffinityGroups API via CLI, I was able to list the new affinity group, including information about the dedicated resources.
CloudMonkey
(local) 🐱 > list affinitygroups
{
"affinitygroup": [
{
"account": "admin",
"dedicatedresources": [
{
"resourceid": "c869ab33-2d16-4ab4-928c-1378d54748ad",
"resourcename": "zn-acs",
"resourcetype": "Zone"
}
],
"description": "Dedicated zone group",
"domain": "ROOT",
"domainid": "f8065d27-38b0-11ef-8103-66e006a45a6c",
"id": "b9d54958-3cc2-4f43-8852-d0d2950593c5",
"name": "DedicatedZoneGrp-admin",
"type": "ExplicitDedication"
}
],
"count": 1
}
The same information was available via UI:
I executed the listAffinityGroups API again, but this time using a second ROOT Admin (admin-test), and it didn't list any affinity group. I tried again using the listall=true parameter and it worked as intended. Through the UI, I had access to all affinity groups without needing an extra filter like the listall parameter.
CloudMonkey
(admin-test) 🐱 > list affinitygroups
(admin-test) 🐱 > list affinitygroups listall=true
{
"affinitygroup": [
{
"account": "admin",
"dedicatedresources": [
{
"resourceid": "c869ab33-2d16-4ab4-928c-1378d54748ad",
"resourcename": "zn-acs",
"resourcetype": "Zone"
}
],
"description": "Dedicated zone group",
"domain": "ROOT",
"domainid": "f8065d27-38b0-11ef-8103-66e006a45a6c",
"id": "b9d54958-3cc2-4f43-8852-d0d2950593c5",
"name": "DedicatedZoneGrp-admin",
"type": "ExplicitDedication"
}
],
"count": 1
}
Using an account with the User role (test), I tried to list all affinity groups via CLI (with and without the listall=true parameter) and UI. In both cases, no affinity groups were listed.
I released the dedicated zone and dedicated it again to the domain ROOT, but this time without specifying an account.
Using the same User account, I tried to list the affinity groups again, and it worked as intended, showing no information about the dedicated resources.
CloudMonkey
(test) 🐱 > list affinitygroups
{
"affinitygroup": [
{
"account": "system",
"description": "Dedicated zone group",
"domain": "ROOT",
"domainid": "f8065d27-38b0-11ef-8103-66e006a45a6c",
"id": "4196e123-8616-4688-b9bb-aeb786945c89",
"name": "DedicatedZoneGrp-domain-ROOT",
"type": "ExplicitDedication"
}
],
"count": 1
}
|
@blueorangutan package |
|
@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10463 |
|
@blueorangutan package |
|
@JoaoJandre a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 10636 |
|
@blueorangutan package |
|
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10650 |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-11073)
|
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
10d97dd to
de9cc41
Compare
|
@blueorangutan package |
|
@bernardodemarco a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10684 |
|
@DaanHoogland, could we run the CI here? |
|
@blueorangutan test |
|
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
|
[SF] Trillian test result (tid-11293)
|
Thanks, I'll check if these test errors are related to the PR's changes. |
|
I took a look at the marvin logs and, although the tests 2024-09-02 20:21:08,522 - CRITICAL - EXCEPTION: test_DeployVmAffinityGroup: ['Traceback (most recent call last):\n', ' File "/usr/lib64/python3.6/unittest/case.py", line 60, in testPartExecutor\n yield\n', ' File "/usr/lib64/python3.6/unittest/case.py", line 622, in run\n testMethod()\n', ' File "/marvin/tests/smoke/test_affinity_groups.py", line 183, in test_DeployVmAffinityGroup\n affinitygroupnames=[self.affinity.name]\n', ' File "/usr/local/lib/python3.6/site-packages/marvin/lib/base.py", line 691, in create\n virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)\n', ' File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackAPI/cloudstackAPIClient.py", line 4051, in deployVirtualMachine\n response = self.connection.marvinRequest(command, response_type=response, method=method)\n', ' File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 381, in marvinRequest\n raise e\n', ' File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 376, in marvinRequest\n raise self.__lastError\n', ' File "/usr/local/lib/python3.6/site-packages/marvin/cloudstackConnection.py", line 105, in __poll\n % async_response)\n', 'Exception: Job failed: {accountid : \'c6541c8f-6961-11ef-9f55-1e009f0003bc\', account : \'admin\', domainid : \'8da7e16b-6961-11ef-9f55-1e009f0003bc\', domainpath : \'ROOT\', userid : \'c654e153-6961-11ef-9f55-1e009f0003bc\', cmd : \'org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin\', jobstatus : 2, jobprocstatus : 0, jobresultcode : 530, jobresulttype : \'object\', jobresult : {errorcode : 530, errortext : "Unable to find on DB, due to: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \') FOR UPDATE\' at line 1"}, jobinstancetype : \'VirtualMachine\', jobinstanceid : \'76c4bd4b-5624-4b0f-837f-015948b82189\', created : \'2024-09-02T20:21:07+0000\', completed : \'2024-09-02T20:21:07+0000\', jobid : \'666bb04f-ec5c-4a45-b4fe-d2bc283c2755\'}\n']These same erros also appeared on #9549 (comment). Furthermore, the pipeline was run previously (#9188 (comment)) and the errors were different. Given that, @DaanHoogland could we run the CI again? |
|
We could @bernardodemarco , but given that @lucas-a-martins has done manual testing, he and I have reviewed and you have checked the regression test errors, I think we can spare the lab space and merge. cc @JoaoJandre ?? |
…s related to an affinity group (apache#9188) * add dedicated resource response * populate dedicatedresources field * change affinity group name and description when it contains dedicated resources * display dedicatedresources on UI * add end of line to DedicatedResourceResponse class * remove unnecessary fully qualified names



Description
When an affinity group is composed of dedicated resources, the
listAffinityGroupsAPI does not show any information about the resources of the group.This PR, therefore, adds which dedicated resources are related to a given affinity group in the
listAffinityGroupsAPI response and displays a link to them in the UI. Furthermore, the affinity groups default title and description were modified in order to reflect the type of the resource that they are associated with.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots:
Affinity group details for Root Admin users
Affinity group details for non Root Admin users
How Has This Been Tested?
Tests with a root admin user
host-02to the domainROOT.host-01to the domainROOT.listAffinityGroupsAPI through CloudMonkey and I got the following response:listAffinityGroups{ "affinitygroup": [ { "account": "system", "dedicatedresources": [ { "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9", "resourcename": "host-02", "resourcetype": "Host" }, { "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3", "resourcename": "host-01", "resourcetype": "Host" } ], "description": "Dedicated host group", "domain": "ROOT", "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e", "id": "6623fe64-2c01-41ba-bf79-58c8fa7c0e16", "name": "DedicatedHostGrp-domain-ROOT", "type": "ExplicitDedication" } ], "count": 1 }Affinity group details image
Tests with a non root admin user
listAffinityGroupsAPI through CloudMonkey and I got the following response:listAffinityGroups{ "affinitygroup": [ { "account": "system", "description": "Dedicated host group", "domain": "ROOT", "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e", "id": "6623fe64-2c01-41ba-bf79-58c8fa7c0e16", "name": "DedicatedHostGrp-domain-ROOT", "type": "ExplicitDedication" } ], "count": 1 }As it can be observed, the
dedicatedresourcesfield was not returned on the response.Affinity group details image