oscaralvaro opened a new pull request, #7506:
URL: https://github.com/apache/cloudstack/pull/7506

   ### Description
   
   In troubleshooting ops issues we see logs like:
   
   Maximum domain resource limits of Type 'user_vm' for Domain Id = 763 is 
exceeded: Domain Resource Limit = (1 bytes) 1, Current Domain Resource Amount = 
(0 bytes) 0, Requested Resource Amount = (1 bytes) 1."
   
   However there is one missing value (currentResourceReservation) that is used 
in the calculation of limit check but it is not logged, which leads to 
confusion. Above we see we are using “0” and requested 1, with our limit being 
1, but was rejected. Without logging all the values used in the calculation we 
don’t understand why it failed.
   
   Additionally, if we had this log above it would be clearer that a second bug 
is occurring. When we query for domain level resource reservations in 
“getDomainReservation” the actual SearchBuilder is the 
listAccountAndTypeSearch, not the listDomainAndTypeSearch. As a result, when we 
call getDomainReservation the query returns any outstanding domain reservation 
for any account, as domain ID is not a valid filter for the account search.
   
   This PR:
   
   - Increases detailed information in log for checking resource limit to 
include reservations information for functions: checkDomainResourceLimit() and 
checkAccountResourceLimit
   
   - Fixes getDomainReservation() to use listDomainAndTypeSearch instead of 
listAccountAndTypeSearch
   
   #### Testing
   Log generation manually tested
   
   #### Log samples
   
   Before the change
   
   (logprefix) ... Checking if amount of resources of Type = 'user_vm' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 20, Current Account Resource Amount = 0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'cpu' for Account 
Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource Limit = 
40, Current Account Resource Amount = 0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'memory' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 40960, Current Account Resource Amount = 0, Requested Resource Amount = 
512.
   (logprefix) ... Checking if amount of resources of Type = 'volume' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 20, Current Account Resource Amount = 0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'primary_storage' 
for Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account 
Resource Limit = (200.00 GB) 214748364800, Current Account Resource Amount = (0 
bytes) 0, Requested Resource Amount = (5.00 GB) 5368709120.
   
   
   After the change
   
   (logprefix) ... Checking if amount of resources of Type = 'user_vm' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 20, Current Account Resource Amount = 1, Current Account Resource 
Reservation = 0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'cpu' for Account 
Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource Limit = 
40, Current Account Resource Amount = 1, Current Account Resource Reservation = 
0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'memory' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 40960, Current Account Resource Amount = 512, Current Account Resource 
Reservation = 0, Requested Resource Amount = 512.
   (logprefix) ... Checking if amount of resources of Type = 'volume' for 
Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account Resource 
Limit = 20, Current Account Resource Amount = 1, Current Account Resource 
Reservation = 0, Requested Resource Amount = 1.
   (logprefix) ... Checking if amount of resources of Type = 'primary_storage' 
for Account Name = domainadmin_user in Domain Id = 1 is exceeded: Account 
Resource Limit = (200.00 GB) 214748364800, Current Account Resource Amount = 
(5.00 GB) 5368709120, Current Account Resource Reservation = (0 bytes) 0, 
Requested Resource Amount = (5.00 GB) 5368709120.
   
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [X] 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)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   


-- 
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