bernardodemarco commented on PR #9188:
URL: https://github.com/apache/cloudstack/pull/9188#issuecomment-2241304416

   @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 Cases
   
   ### Environment
   
   - Accounts: admin (`Root Admin`) and admin2 (`Root Admin`)
   - Domains: ROOT
   - Hosts: host-01 and host-02
   - Clusters: cluster-zn-fln-01
   - Pods: pod-zn-fln-01
   - Zones: zn-fln-01
   
   ---
   
   `host-01` has been dedicated to admin and `host-02` to admin2.
   
   <details>
   <summary><code>listAffinityGroups</code> for admin</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3",
             "resourcename": "host-01",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "46fcaeee-ce9f-40a7-9314-68e338c84092",
         "name": "DedicatedHostGrp-admin",
         "type": "ExplicitDedication"
       }
     ],
     "count": 1
   }
   ```
   
   </details>
   
   <details>
   <summary><code>listAffinityGroups</code> for admin2</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin2",
         "dedicatedresources": [
           {
             "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9",
             "resourcename": "host-02",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "17c28add-86b4-43e7-9cf0-3ba41f6d77f0",
         "name": "DedicatedHostGrp-admin2",
         "type": "ExplicitDedication"
       }
     ],
     "count": 1
   }
   ```
   
   </details>
   
   If the `listall` parameter is set to `true`, all affinity groups will be 
listed for both admins, which is the expected behavior.
   
   <details>
   <summary><code>listAffinityGroups listall=true</code> output for both 
admins</summary>
   
   ```bash
   listAffinityGroups listall=true
   {
     "affinitygroup": [
       {
         "account": "admin2",
         "dedicatedresources": [
           {
             "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9",
             "resourcename": "host-02",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "17c28add-86b4-43e7-9cf0-3ba41f6d77f0",
         "name": "DedicatedHostGrp-admin2",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3",
             "resourcename": "host-01",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "46fcaeee-ce9f-40a7-9314-68e338c84092",
         "name": "DedicatedHostGrp-admin",
         "type": "ExplicitDedication"
       }
     ],
     "count": 2
   }
   ```
   
   </details>
   
   ---
   
   I created a custom affinity group for the `admin` account with the 
`host-affinity` type. Then, I called `listAffinityGroups` API for both admins 
and received the following outputs:
   
   <details>
   <summary><code>listAffinityGroups</code> for admin</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3",
             "resourcename": "host-01",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "4497ce7e-55d5-4dfe-a560-9d488f3ed038",
         "name": "DedicatedHostGrp-admin",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "70621909-06ae-4de2-b1f9-72a830c2c6ce",
         "name": "Low Latency Affinity Group",
         "type": "host affinity"
       }
     ],
     "count": 2
   }
   ```
   
   </details>
   
   <details>
   <summary><code>listAffinityGroups listall=true</code> for admin</summary>
   
   ```bash
   list affinitygroups listall=true
   {
     "affinitygroup": [
       {
         "account": "admin2",
         "dedicatedresources": [
           {
             "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9",
             "resourcename": "host-02",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "bfa1de1b-a81c-4c55-b763-f2672548c551",
         "name": "DedicatedHostGrp-admin2",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3",
             "resourcename": "host-01",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "4497ce7e-55d5-4dfe-a560-9d488f3ed038",
         "name": "DedicatedHostGrp-admin",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "70621909-06ae-4de2-b1f9-72a830c2c6ce",
         "name": "Low Latency Affinity Group",
         "type": "host affinity"
       }
     ],
     "count": 3
   }
   ```
   
   </details>
   
   <details>
   <summary><code>listAffinityGroups</code> for admin2</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin2",
         "dedicatedresources": [
           {
             "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9",
             "resourcename": "host-02",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "bfa1de1b-a81c-4c55-b763-f2672548c551",
         "name": "DedicatedHostGrp-admin2",
         "type": "ExplicitDedication"
       }
     ],
     "count": 1
   }
   ```
   
   </details>
   
   <details>
   <summary><code>listAffinityGroups listall=true</code> for admin2</summary>
   
   ```bash
   list affinitygroups listall=true
   {
     "affinitygroup": [
       {
         "account": "admin2",
         "dedicatedresources": [
           {
             "resourceid": "8a783642-c6a0-4948-8128-61aa73aef8a9",
             "resourcename": "host-02",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "bfa1de1b-a81c-4c55-b763-f2672548c551",
         "name": "DedicatedHostGrp-admin2",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "8928748b-cf9c-46df-b4c8-b39f476ebad3",
             "resourcename": "host-01",
             "resourcetype": "Host"
           }
         ],
         "description": "Dedicated host group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "4497ce7e-55d5-4dfe-a560-9d488f3ed038",
         "name": "DedicatedHostGrp-admin",
         "type": "ExplicitDedication"
       },
       {
         "account": "admin",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "70621909-06ae-4de2-b1f9-72a830c2c6ce",
         "name": "Low Latency Affinity Group",
         "type": "host affinity"
       }
     ],
     "count": 3
   }
   ```
   
   </details>
   
   ---
   
   I released the `host-02` dedication from admin2 and dedicated it to admin. 
Later, I dedicated the cluster `cluster-zn-fln-01`, which contains the hosts 
`host-01` and `host-02`, to admin. CloudStack automatically created a new 
affinity group representing the cluster dedication and removed the affinity 
group related to the hosts dedications, since all hosts within the given 
cluster were already dedicated to the same account as the cluster.
   
   <details>
   <summary><code>listAffinityGroups</code> for admin</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "70621909-06ae-4de2-b1f9-72a830c2c6ce",
         "name": "Low Latency Affinity Group",
         "type": "host affinity"
       },
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "d1050b75-b522-4371-9726-39b224e5d4c5",
             "resourcename": "Cluster-zn-fln-01",
             "resourcetype": "Cluster"
           }
         ],
         "description": "Dedicated cluster group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "96bd929c-c622-4db0-a591-a91520f15b4c",
         "name": "DedicatedClusterGrp-admin",
         "type": "ExplicitDedication"
       }
     ],
     "count": 2
   }
   ```
   
   </details>
   
   This behavior is consistent across all infrastructure resources. If the pod 
`pod-zn-fln-01` is dedicated to admin, CloudStack will delete the cluster's 
affinity group and create a new one related to the pod.
   
   <details>
   <summary><code>listAffinityGroups</code> for admin</summary>
   
   ```bash
   list affinitygroups 
   {
     "affinitygroup": [
       {
         "account": "admin",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "70621909-06ae-4de2-b1f9-72a830c2c6ce",
         "name": "Low Latency Affinity Group",
         "type": "host affinity"
       },
       {
         "account": "admin",
         "dedicatedresources": [
           {
             "resourceid": "007fe264-78a5-42b3-9523-7e77a593ae04",
             "resourcename": "Pod-zn-fln-01",
             "resourcetype": "Pod"
           }
         ],
         "description": "Dedicated pod group",
         "domain": "ROOT",
         "domainid": "ba820fc7-12ea-11ef-9500-d283eea8b15e",
         "id": "7940435f-3ed5-4e43-8099-09ae6d65cebd",
         "name": "DedicatedPodGrp-admin",
         "type": "ExplicitDedication"
       }
     ],
     "count": 2
   }
   ```
   </details>
   
   ---
   
   It's important to highlight that this PR does not change or affect any 
workflows related to resource dedications and affinity groups creation. It 
simply proposes to enhance the `listAffinityGroups` API response by adding the 
`dedicatedresources` field for root admins and by changing the default affinity 
groups' names and descriptions.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to