Skip to content

Conversation

@shwstppr
Copy link
Contributor

@shwstppr shwstppr commented Sep 6, 2025

Description

Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while other return it as '/domain1/domain2'. This PR makes the response consistent.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Before:

(localcloud) 🐱 > list networks listall=true filter=id,name,domainpath
{
  "count": 2,
  "network": [
    {
      "domainpath": "/d1/d11/",
      "id": "5f58ee16-9140-4241-a50f-3c079b9717e1",
      "name": "d11user-network"
    },
    {
      "domainpath": "/",
      "id": "67c1bb61-1155-4b49-9288-543abd95e7ce",
      "name": "abc"
    }
  ]
}
(localcloud) 🐱 > list accounts listall=true filter=id,name,domainpath
{
  "account": [
    {
      "domainpath": "ROOT",
      "id": "b1962584-8a72-11f0-8f55-a02942fcdd70",
      "name": "admin"
    },
    {
      "domainpath": "ROOT",
      "id": "0b56a8ae-5b2d-4b15-ae7d-2a7209e25d18",
      "name": "baremetal-system-account"
    },
    {
      "domainpath": "ROOT/d1/d11",
      "id": "0a5340ac-4e5c-4cc2-9c1c-dd00014e36b5",
      "name": "d11user"
    }
  ],
  "count": 3
}

After:

(localcloud) 🐱 > list networks listall=true filter=id,name,domainpath
{
  "count": 2,
  "network": [
    {
      "domainpath": "ROOT/d1/d11",
      "id": "5f58ee16-9140-4241-a50f-3c079b9717e1",
      "name": "d11user-network"
    },
    {
      "domainpath": "ROOT",
      "id": "67c1bb61-1155-4b49-9288-543abd95e7ce",
      "name": "abc"
    }
  ]
}
(localcloud) 🐱 > list accounts listall=true filter=id,name,domainpath
{
  "account": [
    {
      "domainpath": "ROOT",
      "id": "b1962584-8a72-11f0-8f55-a02942fcdd70",
      "name": "admin"
    },
    {
      "domainpath": "ROOT",
      "id": "0b56a8ae-5b2d-4b15-ae7d-2a7209e25d18",
      "name": "baremetal-system-account"
    },
    {
      "domainpath": "ROOT/d1/d11",
      "id": "0a5340ac-4e5c-4cc2-9c1c-dd00014e36b5",
      "name": "d11user"
    }
  ],
  "count": 3
}

How did you try to break this feature and the system with this change?

Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while
other return it as '/domain1/domain2'. This PR makes the response
consistent.

Signed-off-by: Abhishek Kumar <[email protected]>
@codecov
Copy link

codecov bot commented Sep 6, 2025

Codecov Report

❌ Patch coverage is 28.94737% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.56%. Comparing base (3ddd802) to head (64fc1f3).
⚠️ Report is 115 commits behind head on main.

Files with missing lines Patch % Lines
...src/main/java/com/cloud/api/ApiResponseHelper.java 35.71% 16 Missing and 2 partials ⚠️
...cloudstack/api/command/user/vpn/AddVpnUserCmd.java 0.00% 1 Missing ⚠️
...apache/cloudstack/api/response/UserVmResponse.java 0.00% 0 Missing and 1 partial ⚠️
...bernetes/cluster/KubernetesClusterManagerImpl.java 0.00% 1 Missing ⚠️
...dstack/api/response/KubernetesClusterResponse.java 0.00% 1 Missing ⚠️
...va/com/cloud/api/query/dao/AccountJoinDaoImpl.java 0.00% 1 Missing ⚠️
...a/com/cloud/api/query/dao/AsyncJobJoinDaoImpl.java 0.00% 1 Missing ⚠️
...ava/com/cloud/api/query/dao/DomainJoinDaoImpl.java 0.00% 1 Missing ⚠️
...cloud/api/query/dao/ProjectAccountJoinDaoImpl.java 0.00% 1 Missing ⚠️
...ud/api/query/dao/ProjectInvitationJoinDaoImpl.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11589      +/-   ##
============================================
+ Coverage     17.36%   17.56%   +0.20%     
- Complexity    15235    15491     +256     
============================================
  Files          5888     5897       +9     
  Lines        525740   528179    +2439     
  Branches      64164    64716     +552     
============================================
+ Hits          91272    92801    +1529     
- Misses       424168   424950     +782     
- Partials      10300    10428     +128     
Flag Coverage Δ
uitests 3.59% <ø> (-0.04%) ⬇️
unittests 18.62% <28.94%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shwstppr
Copy link
Contributor Author

shwstppr commented Sep 6, 2025

@blueorangutan package

@blueorangutan
Copy link

@shwstppr 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.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 14879

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my preference would be to remove the word ‘ROOT’ but CLGTM (also potaeto/potahto)

Signed-off-by: Abhishek Kumar <[email protected]>
@shwstppr
Copy link
Contributor Author

shwstppr commented Oct 8, 2025

@harikrishna-patnala I've made changes to normalize domain path across code now.
We can decide if we want ROOT/<domain_path> or /<domain_path> or <domain_path> @DaanHoogland
It will be easier to change that now.

@blueorangutan package

@blueorangutan
Copy link

@shwstppr 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.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15338

@harikrishna-patnala
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@harikrishna-patnala a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@DaanHoogland DaanHoogland requested a review from Copilot October 8, 2025 12:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR standardizes the format of domainpath fields in API responses across all endpoints. Previously, some APIs returned domainpath as 'ROOT/domain1/domain2' while others returned it as '/domain1/domain2'. The changes ensure all APIs consistently return the "ROOT/..." format.

  • Centralized domain path formatting logic in a new utility method getPrettyDomainPath()
  • Refactored multiple DAO implementations to use common helper methods for owner/domain population
  • Updated response interfaces to support the consolidated approach

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

File Description
ApiResponseHelper.java Added getPrettyDomainPath() utility method and consolidated owner/domain population logic
Multiple DAO implementations Removed duplicated domain path logic and switched to use centralized helper methods
Response classes Updated interfaces to support unified response handling
AddVpnUserCmd.java Refactored to use response generator instead of manual response construction

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

return null;
}
StringBuilder domainPath = new StringBuilder("ROOT");
(domainPath.append(path)).deleteCharAt(domainPath.length() - 1);
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method assumes path always ends with a character that can be deleted, but if path is empty or doesn't end with a trailing character, deleteCharAt(domainPath.length() - 1) will throw a StringIndexOutOfBoundsException.

Suggested change
(domainPath.append(path)).deleteCharAt(domainPath.length() - 1);
if (path != null && !path.isEmpty()) {
domainPath.append(path);
// Remove trailing '/' if present
if (domainPath.length() > 0 && domainPath.charAt(domainPath.length() - 1) == '/') {
domainPath.deleteCharAt(domainPath.length() - 1);
}
}

Copilot uses AI. Check for mistakes.
response.setDomainPath(getPrettyDomainPath(domain.getPath()));
}

private static void populateDomain(ControlledViewEntityResponse response, long domainId) {
Copy link

Copilot AI Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is declared as private static but needs to be accessible from other classes. It should be public static to match the usage pattern of other helper methods in this class.

Suggested change
private static void populateDomain(ControlledViewEntityResponse response, long domainId) {
public static void populateDomain(ControlledViewEntityResponse response, long domainId) {

Copilot uses AI. Check for mistakes.
@DaanHoogland
Copy link
Contributor

@shwstppr I prefer "/" but am not going to make a big issue about it. what do you think @harikrishna-patnala ?

@blueorangutan
Copy link

[SF] Trillian test result (tid-14576)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 54029 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11589-t14576-kvm-ol8.zip
Smoke tests completed. 149 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@harikrishna-patnala
Copy link
Contributor

@shwstppr I prefer "/" but am not going to make a big issue about it. what do you think @harikrishna-patnala ?

Both are fine, but ROOT/ seems better to me as it implies directly and we are showing the domain as ROOT in UI as well.

@harikrishna-patnala harikrishna-patnala merged commit a6ef24d into apache:main Oct 9, 2025
51 of 52 checks passed
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Oct 17, 2025
* server: consistent domainpath in api responses

Currently, some APIs return domainpath as 'ROOT/domain1/domain2' while
other return it as '/domain1/domain2'. This PR makes the response
consistent like "ROOT/domain1/domain2"

Signed-off-by: Abhishek Kumar <[email protected]>

* more changes

Signed-off-by: Abhishek Kumar <[email protected]>

---------

Signed-off-by: Abhishek Kumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants