Skip to content

Fix VM and volume metrics listing regressions - #12284

Merged
DaanHoogland merged 4 commits into
apache:4.20from
winterhazel:fix-metrics-listing-regression
Dec 20, 2025
Merged

Fix VM and volume metrics listing regressions#12284
DaanHoogland merged 4 commits into
apache:4.20from
winterhazel:fix-metrics-listing-regression

Conversation

@winterhazel

@winterhazelwinterhazel commented Dec 18, 2025

Copy link
Copy Markdown
Member

Description

This PR fixes a regression in commit c8d44d9 that prevents non-admin accounts from listing the metrics of VMs and volumes that belong to a project (see #12237).

Previously, the following example condition was used in the listVirtualMachinesMetrics API in order to find VMs that could have their metrics listed by a user:

vm_instance.type='User' AND user_vm.id=88 AND vm_instance.removed IS NULL

In 4.20.2 and 4.22.0, the condition also restricts the result to VMs that belong to the calling account; hence, VMs that belong to a project are not returned:

WHERE vm_instance.type='User' AND vm_instance.account_id=6 AND user_vm.id=88 AND vm_instance.removed IS NULL

With this patch, the ID of projects that the user has access to is also included in the condition:

WHERE vm_instance.type='User' AND vm_instance.account_id IN (11,6) AND user_vm.id=88 AND vm_instance.removed IS NULL

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

I manually verified that, using both the id and ids parameters:

  • Root admins can access the metrics of VMs/volumes belonging to other users and projects
  • Domain admins can access the metrics of VMs/volumes belonging to users and projects of their domain
  • Users can access the metrics of VMs/volumes belonging to them and to projects they have access to

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@codecov

codecovBot commented Dec 18, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 16.23%. Comparing base (ba26d95) to head (67c5241).
⚠️ Report is 3 commits behind head on 4.20.

Additional details and impacted files
@@ Coverage Diff @@## 4.20 #12284 +/- ##
============================================
+ Coverage 16.22% 16.23% +0.01% - Complexity 13358 13379 +21 
============================================
Files 5657 5657 Lines 498692 498865 +173 Branches 60530 60545 +15 ============================================
+ Hits 80932 81011 +79 - Misses 408738 408820 +82 - Partials 9022 9034 +12 
FlagCoverage Δ
uitests4.00% <ø> (ø)
unittests17.09% <100.00%> (+0.01%)⬆️

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.

@blueorangutan

Copy link
Copy Markdown

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

@kiranchavalakiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

  1. Created a user in a domain
  2. Login, as the user and Create a project
  3. Deploy a vm in the project and check the metrics tab

Before fix

the API listVirtualMachinesUsageHistory has no response

Screenshot 2025-12-18 at 4 02 27 PM

After fix

the API listVirtualMachinesUsageHistory has response

Screenshot 2025-12-18 at 4 53 35 PM

@DaanHooglandDaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clgtm, one remark/question though; two bits of code are repeated with a similar statement in between, Can we create a method for it?

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@kiranchavala thanks for testing :]

@DaanHoogland yup, I will do some refactoring (and some extra tests to be sure) before marking it as ready.

@winterhazelwinterhazel changed the title Fix VM and volume metrics listing regressionFix VM and volume metrics listing regressionsDec 18, 2025
@winterhazel
winterhazel marked this pull request as ready for review December 18, 2025 20:11
@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16090

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@DaanHoogland I extracted the code that builds the parameters to a method. Tests are also ok.

I noticed that there was another regression in which admins were not able to list the metrics of VMs/volumes belonging to projects via the ids parameter. It should be fixed now too.

Example
<before>
(admin) 🐢 > list virtualmachinesusagehistory id=69ecb2a6-dc91-46b9-a5d9-06e8222c5084
{
"count": 1,
"virtualmachine": [
{
"displayname": "k",
"id": "69ecb2a6-dc91-46b9-a5d9-06e8222c5084",
"name": "i-2-88-VM",
"stats": [
{
"cpuused": "0%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:21:54+0000"
},
{
"cpuused": "20.77%",
"diskiopstotal": 835,
"diskioread": 640,
"diskiowrite": 195,
"diskkbsread": 10876,
"diskkbswrite": 1612,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 2,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:22:54+0000"
},
{
"cpuused": "13.52%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:23:54+0000"
}
]
}
]
}
(admin) 🐢 > list virtualmachinesusagehistory ids=69ecb2a6-dc91-46b9-a5d9-06e8222c5084
<empty>
<with the patch>
(admin) 🐢 > list virtualmachinesusagehistory ids=69ecb2a6-dc91-46b9-a5d9-06e8222c5084
{
"count": 1,
"virtualmachine": [
{
"displayname": "k",
"id": "69ecb2a6-dc91-46b9-a5d9-06e8222c5084",
"name": "i-2-88-VM",
"stats": [
{
"cpuused": "0%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:21:54+0000"
},
{
"cpuused": "20.77%",
"diskiopstotal": 835,
"diskioread": 640,
"diskiowrite": 195,
"diskkbsread": 10876,
"diskkbswrite": 1612,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 2,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:22:54+0000"
},
{
"cpuused": "13.52%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:23:54+0000"
},
{
"cpuused": "60.96%",
"diskiopstotal": 1116,
"diskioread": 902,
"diskiowrite": 214,
"diskkbsread": 67400,
"diskkbswrite": 2040,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:24:55+0000"
},
{
"cpuused": "40.05%",
"diskiopstotal": 277,
"diskioread": 110,
"diskiowrite": 167,
"diskkbsread": 13304,
"diskkbswrite": 38524,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:25:56+0000"
},
{
"cpuused": "26.1%",
"diskiopstotal": 3,
"diskioread": 0,
"diskiowrite": 3,
"diskkbsread": 0,
"diskkbswrite": 16,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:26:58+0000"
},
{
"cpuused": "25.4%",
"diskiopstotal": 1,
"diskioread": 0,
"diskiowrite": 1,
"diskkbsread": 0,
"diskkbswrite": 4,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:27:59+0000"
},
{
"cpuused": "24.83%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:29:02+0000"
},
{
"cpuused": "24.91%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:30:04+0000"
},
{
"cpuused": "25.87%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:31:09+0000"
},
{
"cpuused": "25.24%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:32:11+0000"
},
{
"cpuused": "20.79%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:33:12+0000"
},
{
"cpuused": "6.03%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:34:13+0000"
},
{
"cpuused": "5.77%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:35:13+0000"
},
{
"cpuused": "5.78%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:36:13+0000"
},
{
"cpuused": "7.01%",
"diskiopstotal": 158,
"diskioread": 103,
"diskiowrite": 55,
"diskkbsread": 412,
"diskkbswrite": 472,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:37:13+0000"
},
{
"cpuused": "8.05%",
"diskiopstotal": 3,
"diskioread": 0,
"diskiowrite": 3,
"diskkbsread": 0,
"diskkbswrite": 16,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:38:14+0000"
},
{
"cpuused": "8.79%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:39:14+0000"
},
{
"cpuused": "6.4%",
"diskiopstotal": 0,
"diskioread": 0,
"diskiowrite": 0,
"diskkbsread": 0,
"diskkbswrite": 0,
"memoryintfreekbs": 353728,
"memorykbs": 524288,
"memorytargetkbs": 524288,
"networkkbsread": 0,
"networkkbswrite": 0,
"networkread": "0.00 MiB",
"networkwrite": "0.00 MiB",
"timestamp": "2025-12-18T19:40:14+0000"
}
]
}
]
}

Also, passing the ids parameter to listVolumesUsageHistory was throwing an exception. I took the opportunity to fix this here as well.

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16091

@winterhazel

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@winterhazel 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
Copy Markdown

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16092

@DaanHoogland

Copy link
Copy Markdown
Contributor

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 16092

we hit the github API limit @winterhazel , don’t worry about this.

@blueorangutan

Copy link
Copy Markdown

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

@DaanHoogland

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File

@DaanHoogland
DaanHoogland merged commit 061ce9b into apache:4.20Dec 20, 2025
26 checks passed
DaanHoogland pushed a commit that referenced this pull request Dec 22, 2025
* 4.22:
Update templateConfig.sh to not break with directorys with space on t… (#10898)
Fix VM and volume metrics listing regressions (#12284)
packaging: use latest cmk release link directly (#11429)
api:rename RegisterCmd.java => RegisterUserKeyCmd.java (#12259)
Prioritize copying templates from other secondary storages instead of downloading them (#10363)
Show time correctly in the backup schedule UI (#12012)
kvm: use preallocation option for fat disk resize (#11986)
Python exception processing static routes fixed (#11967)
KVM memballooning requires free page reporting and autodeflate (#11932)
api: create/register/upload template with empty template tag (#12234)
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jan 21, 2026
sandeeplocharla pushed a commit to NetApp/cloudstack that referenced this pull request Feb 6, 2026
Sign up for freeto 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

@winterhazel@blueorangutan@DaanHoogland@kiranchavala@weizhouapache