guard against stopping stats background threads#13659
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #13659 +/- ##
=========================================
Coverage 16.26% 16.26%
- Complexity 13435 13436 +1
=========================================
Files 5667 5667
Lines 500731 500739 +8
Branches 60803 60803
=========================================
+ Hits 81430 81458 +28
+ Misses 410197 410174 -23
- Partials 9104 9107 +3
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:
|
|
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent the periodic VM/Volume stats cleanup background tasks in StatsCollector from being permanently stopped when a cleanup run throws an exception (per #13648).
Changes:
- Wrapped
VmStatsCleanerandVolumeStatsCleanercleanup calls in try/catch blocks to avoid uncaught exceptions escaping the scheduled task. - Added unit tests for volume stats cleanup enable/disable behavior and for cleaner exception handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
server/src/main/java/com/cloud/server/StatsCollector.java |
Adds exception handling around scheduled cleanup runnables to prevent task termination. |
server/src/test/java/com/cloud/server/StatsCollectorTest.java |
Adds tests covering volume stats cleanup gating and cleaner exception scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| cleanUpVirtualMachineStats(); | ||
| } catch (CloudRuntimeException e) { | ||
| logger.error("Error trying to clean up VM stats", e); | ||
| } |
There was a problem hiding this comment.
| try { | |
| cleanUpVirtualMachineStats(); | |
| } catch (CloudRuntimeException e) { | |
| logger.error("Error trying to clean up VM stats", e); | |
| } | |
| try { | |
| cleanUpVirtualMachineStats(); | |
| } catch (RuntimeException e) { | |
| logger.error("Error trying to clean up VM stats", e); | |
| } |
at best!
| try { | ||
| cleanUpVolumeStats(); | ||
| } catch (CloudRuntimeException e) { | ||
| logger.error("Error trying to clean up Volume stats", e); | ||
| } |



Description
This PR...
Fixes: #13648
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?