Skip to content

Conversation

@abh1sar
Copy link
Collaborator

@abh1sar abh1sar commented Jul 29, 2025

Description

This PR fixes listCapacity api's sort by usage parameter.

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:

(localhost) 🐱 > list capacity  sortby="usage"                                                                                                                                                                                                                                                                  [21/495]
{                                                                             
  "capacity": [                                                               
    {                                                                         
      "capacitytotal": 6997340160,                                            
      "capacityused": 5368709120,                                             
      "name": "MEMORY",                                                       
      "percentused": "76.72",                                                 
      "type": 0,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 14400,                                                 
      "capacityused": 4500,                                                   
      "name": "CPU",                                                          
      "percentused": "31.25",                                                 
      "type": 1,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 0,                                                     
      "capacityused": 0,                                                      
      "name": "STORAGE",                                                      
      "percentused": "0",                                                     
      "type": 2,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 1572431986688,                                         
      "capacityused": 0,                                                      
      "name": "STORAGE_ALLOCATED",                                            
      "percentused": "0",                                                     
      "type": 3,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 125,                                                   
      "capacityused": 5,                                                      
      "name": "VIRTUAL_NETWORK_PUBLIC_IP",                                    
      "percentused": "4",                                                     
      "type": 4,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 125,                                                   
      "capacityused": 2,                                                      
      "name": "PRIVATE_IP",                                                   
      "percentused": "1.6",                                                   
      "type": 5,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 0,                                                     
      "capacityused": 0,                                                      
      "name": "SECONDARY_STORAGE",                                            
      "percentused": "0",                                                     
      "type": 6,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 100,                                                   
      "capacityused": 3,                                                      
      "name": "VLAN",                                                         
      "percentused": "3",                                                     
      "type": 7,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 0,                                                     
      "capacityused": 0,                                                      
      "name": "GPU",                                                          
      "percentused": "0",                                                     
      "type": 19,                                                             
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                 

After:

(localhost) 🐱 > list capacity  sortby="usage"                                
{                                                                             
  "capacity": [                                                               
    {                                                                         
      "capacitytotal": 4,                                                     
      "capacityused": 9,                                                      
      "name": "CPU_CORE",                                                     
      "percentused": "225",                                                   
      "type": 90,                                                             
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 6997340160,                                            
      "capacityused": 5368709120,                                             
      "name": "MEMORY",                                                       
      "percentused": "76.72",                                                 
      "type": 0,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 393107996672,                                          
      "capacityused": 301029392384,                                           
      "name": "SECONDARY_STORAGE",                                            
      "percentused": "76.58",                                                 
      "type": 6,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 786215993344,                                          
      "capacityused": 602058784768,                                           
      "name": "STORAGE",                                                      
      "percentused": "76.58",                                                 
      "type": 2,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 393107996672,                                          
      "capacityused": 301026246656,                                           
      "name": "BACKUP_STORAGE",                                               
      "percentused": "76.58",                                                 
      "type": 21,                                                             
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 14400,                                                 
      "capacityused": 4500,                                                   
      "name": "CPU",                                                          
      "percentused": "31.25",                                                 
      "type": 1,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 125,                                                   
      "capacityused": 5,                                                      
      "name": "VIRTUAL_NETWORK_PUBLIC_IP",                                    
      "percentused": "4",                                                     
      "type": 4,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 1572431986688,                                         
      "capacityused": 60574728480,                                            
      "name": "STORAGE_ALLOCATED",                                            
      "percentused": "3.85",                                                  
      "type": 3,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                                        
    {                                                                         
      "capacitytotal": 100,                                                   
      "capacityused": 3,                                                      
      "name": "VLAN",                                                         
      "percentused": "3",                                                     
      "type": 7,                                                              
      "zoneid": "16cc239c-adbc-49cf-b100-4e3ce08ab858",                       
      "zonename": "DC"                                                        
    },                                                               

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

@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 15.17%. Comparing base (ca6d2dc) to head (21d509a).
⚠️ Report is 5 commits behind head on 4.19.

Files with missing lines Patch % Lines
...ck/api/command/admin/resource/ListCapacityCmd.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.19   #11316   +/-   ##
=========================================
  Coverage     15.17%   15.17%           
- Complexity    11362    11364    +2     
=========================================
  Files          5415     5415           
  Lines        476030   476043   +13     
  Branches      58115    58117    +2     
=========================================
+ Hits          72246    72255    +9     
- Misses       395701   395703    +2     
- Partials       8083     8085    +2     
Flag Coverage Δ
uitests 4.28% <ø> (ø)
unittests 15.90% <0.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.

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm

@sureshanaparti
Copy link
Contributor

@blueorangutan package

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 fixes a bug in the listCapacity API where the sort by usage parameter was not working correctly. The issue was that when sorting by usage, the comparator would fall back to sorting by capacity type even when a specific sort parameter was provided.

  • Fixes comparator logic to respect the sortBy parameter when zones have the same name
  • Prevents unintended fallback to capacity type sorting when sortBy is specified

@borisstoyanov borisstoyanov self-assigned this Jul 29, 2025
@borisstoyanov
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@borisstoyanov 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 ✔️ debian ✔️ suse15. SL-JID 14436

@borisstoyanov
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jul 29, 2025

@blueorangutan package

@blueorangutan
Copy link

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

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.

clgtm

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File

Copy link
Contributor

@borisstoyanov borisstoyanov left a comment

Choose a reason for hiding this comment

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

LGTM, manually checked it

@DaanHoogland DaanHoogland merged commit 294aef5 into apache:4.19 Jul 30, 2025
25 of 26 checks passed
@DaanHoogland DaanHoogland deleted the list-capacity branch July 30, 2025 12:05
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Aug 6, 2025
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