Repository navigation
Conversation
recalculateDomainResourceCount() assumed the domain already has a count row for the type and tag. When a tagged domain count is missing and the recalculated usage is not zero, it dereferenced null, so updateResourceCount failed with a NullPointerException and the periodic ResourceCountChecker failed the same way on every run. Create the missing domain count with the recalculated value, the same way recalculateAccountResourceCount() does for accounts. Fixes apache#14729
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.20 #14964 +/- ##
=========================================
Coverage 16.46% 16.46%
+ Complexity 13713 13712 -1
=========================================
Files 5670 5670
Lines 501771 501773 +2
Branches 60965 60966 +1
=========================================
+ Hits 82610 82629 +19
+ Misses 409906 409883 -23
- Partials 9255 9261 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
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:
After:
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.