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

   ### Description
   
   This PR addresses two false positives in the Usage sanity checker:
   
   (1)
   
   A sanity check verifies if there are usage records of a template/ISO created 
after the template/ISO was removed.
   
   In an environment with two zones, if a template gets removed from a zone and 
added back to it, `cloud.template_zone_ref` will have two entries related to 
the template; one marked as `removed`. In this situation, the operator will 
receive a false positive stating that there are usage records for the 
template/ISO after it was removed, even though the template/ISO is available in 
that zone.
   
   This check was changed to verify if the template/ISO is currently available 
in that zone.
   
   (2)
   
   A sanity check verifies if there are usage records with a raw usage greater 
than the aggregation range.
   
   If a VM has more than one NIC using the same network offering, CloudStack 
will group the usage of both NICs into a single network offering usage record; 
for example, two NICs used for 1 hour will result in an entry with a raw usage 
of 2 hours. In this situation, the operator will receive a false positive 
stating that there are usage records with a raw usage greater than the 
aggregation range.
   
   This check was changed to consider the average usage of the NICs, instead of 
the raw usage.
   
   
   ### 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
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [X] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):
   
   
   ### How Has This Been Tested?
   
   I changed the initial delay in `UsageManagerImpl.java#L315` to 0 in order to 
run the sanity checks immediately when Usage starts. Then, whenever I wanted to 
run the sanity checks, I would set the last checked id in 
`/usr/local/libexec/sanity-check-last-id` to 1 and restart Usage.
   
   To simulate the scenario in (1), I created the zone `zone2`, copied a 
template that was being used in `zone1` to `zone2` and deleted the template 
from `zone1`. Then, I copied it from `zone2` to `zone1`.
   
   Before applying the changes:
   - I ran the sanity checks and verified that CloudStack reported template/ISO 
usage records created after it was removed;
   
   After applying the changes
   - I ran the sanity checks and verified that no errors were found;
   - I deleted the template from `zone1`, ran the sanity checks again and 
verified that CloudStack reported template/ISO usage records created after it 
was removed.
   
   To simulate the scenario in (2), I set `usage.stats.job.aggregation.range` 
to 60 (hourly), created a VM with two NICs and waited until there were network 
offering usage records corresponding to the NICs. I verified that `raw_usage` 
was indeed 2.
   
   Before applying the changes:
   - I ran the sanity checks and verified that CloudStack reported usage 
records with `raw_usage` greater than 1.
   
   After applying the changes:
   - I ran the sanity checks and verified that CloudStack did not report usage 
records with `raw_usage` greater than 1;
   - I manually changed the `raw_usage` of a usage record from 2 to 3, ran the 
sanity checks again and verified that CloudStack reported network offering 
usage records with `raw_usage` greater than 1.


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