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

   ### Description
   
   When a domain has no count row for a tagged resource (for example volume 
with a storage tag) but its accounts have usage, 
recalculateDomainResourceCount() dereferenced the missing row. 
updateResourceCount failed with a NullPointerException (HTTP 530), and the 
periodic ResourceCountChecker failed the same way on every run, so the count 
never recovered. There was a TODO in the code for exactly this.
   
   This creates the missing domain count with the recalculated value, the same 
way recalculateAccountResourceCount() already does for accounts.
   
   Fixes: #14729
   
   ### 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)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [x] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   N/A
   
   ### How Has This Been Tested?
   
   Unit tests for a missing and an existing domain count. The missing count 
test fails without the fix with the same NullPointerException as the issue, and 
passes with it.
   
   Reproduced on a KVM lab (main, the method is the same as on 4.20): set 
resource.limit.storage.tags, created a volume with a disk offering carrying 
that tag, deleted the root domain's volume count row for the tag and ran 
updateResourceCount.
   
   Before:
   
       updateResourceCount  530  Cannot invoke 
"com.cloud.configuration.ResourceCountVO.setCount(long)" because "domainRC" is 
null
       the domain volume count row for the tag is still missing
   
   After:
   
       updateResourceCount  OK, volume count 1 for the tag
       the domain volume count row is recreated with count 1
   
   Running it again keeps the count correct.
   
   #### How did you try to break this feature and the system with this change?
   
   A domain with an existing count row still goes through the update path 
(covered by the second unit test). A domain whose recalculated count is 0 and 
has no row is left as it is, same as before.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to