Refactor alert email generation method
Description
The method that generates the alert e-mail contains code repeated in many places and is not formatted properly.
This PR intends to refactor this method.
Types of changes
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Enhancement (improves an existing feature and functionality)
- [X] Cleanup (Code refactoring and cleanup, that may add test cases)
- [ ] build/CI
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
- [ ] Major
- [x] Minor
Bug Severity
- [ ] BLOCKER
- [ ] Critical
- [ ] Major
- [ ] Minor
- [ ] Trivial
Screenshots (if appropriate):
How Has This Been Tested?
I changed the value of many notification threshold global settings to 0% (zone.vlan.capacity.notificationthreshold and cluster.memory.allocated.capacity.notificationthreshold for example). Then I checked through the logs that the messages were created correctly.
2024-03-25T18:22:03,626 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[4] dataCenterId=[1] podId=[null] clusterId=[null] message=[System Alert: Number of unallocated virtual network public IPs is low in availability zone [zn-test].].
2024-03-25T18:22:04,487 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Low Available Secondary Storage in availability zone [zn-test].] and content [Available secondary storage space is low, total: 60212 MB, used: 5476 MB (9.09%).].
2024-03-25T18:22:04,488 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[6] dataCenterId=[1] podId=[null] clusterId=[null] message=[System Alert: Low Available Secondary Storage in availability zone [zn-test].].
2024-03-25T18:22:04,503 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Number of unallocated VLANs is low in availability zone [zn-test].] and content [Number of unallocated VLANs is low, total: 101.0, allocated: 6.0 (5.94%).].
2024-03-25T18:22:04,504 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[18] dataCenterId=[1] podId=[null] clusterId=[null] message=[System Alert: Number of unallocated VLANs is low in availability zone [zn-test].].
2024-03-25T18:22:04,534 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Number of unallocated private IPs is low in pod Pod-zn-test of availability zone [zn-test].] and content [Number of unallocated private IPs is low, total: 10.0, allocated: 2.0 (20%)].
2024-03-25T18:22:04,534 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[5] dataCenterId=[1] podId=[1] clusterId=[null] message=[System Alert: Number of unallocated private IPs is low in pod Pod-zn-test of availability zone [zn-test].].
2024-03-25T18:22:06,243 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Low Unallocated CPU in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].] and content [Unallocated CPU is low, total: 30000 Mhz, used: 2500 Mhz (8.33%).].
2024-03-25T18:22:06,244 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[1] dataCenterId=[1] podId=[1] clusterId=[1] message=[System Alert: Low Unallocated CPU in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].].
2024-03-25T18:22:06,263 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Low Available Memory in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].] and content [System memory is low, total: 21914 MB, used: 2560 MB (11.68%).].
2024-03-25T18:22:06,263 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[0] dataCenterId=[1] podId=[1] clusterId=[1] message=[System Alert: Low Available Memory in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].].
2024-03-25T18:22:06,292 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Low Available Storage in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].] and content [Available storage space is low, total: 19019 MB, used: 4317 MB (22.7%).].
2024-03-25T18:22:06,293 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[2] dataCenterId=[1] podId=[1] clusterId=[1] message=[System Alert: Low Available Storage in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].].
2024-03-25T18:22:06,323 DEBUG [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) Sending alert with subject [System Alert: Remaining unallocated Storage is low in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].] and content [Unallocated storage space is low, total: 38037 MB, allocated: 20000 MB (52.58%)].
2024-03-25T18:22:06,324 WARN [c.c.a.AlertManagerImpl] (CapacityChecker:[ctx-73e84063]) (logid:0ebef2c9) alertType=[3] dataCenterId=[1] podId=[1] clusterId=[1] message=[System Alert: Remaining unallocated Storage is low in cluster [Cluster-zn-test] pod [Pod-zn-test] of availability zone [zn-test].].
@blueorangutan package
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
Codecov Report
Attention: Patch coverage is 0% with 65 lines in your changes missing coverage. Please review.
Project coverage is 16.02%. Comparing base (
085bd3b) to head (60d35a9). Report is 75 commits behind head on 4.20.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...rc/main/java/com/cloud/alert/AlertManagerImpl.java | 0.00% | 65 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## 4.20 #8831 +/- ##
============================================
+ Coverage 4.02% 16.02% +12.00%
- Complexity 0 13149 +13149
============================================
Files 394 5658 +5264
Lines 32357 496291 +463934
Branches 5728 60110 +54382
============================================
+ Hits 1301 79538 +78237
- Misses 30907 407904 +376997
- Partials 149 8849 +8700
| Flag | Coverage Δ | |
|---|---|---|
| uitests | 4.01% <ø> (-0.01%) |
:arrow_down: |
| unittests | 16.86% <0.00%> (?) |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9092
@blueorangutan test alma9 kvm-alma9
@DaanHoogland a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests
[SF] Trillian test result (tid-9652) Environment: kvm-alma9 (x2), Advanced Networking with Mgmt server a9 Total time taken: 51042 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8831-t9652-kvm-alma9.zip Smoke tests completed. 129 look OK, 0 have errors, 0 did not run Only failed and skipped tests results shown below:
| Test | Result | Time (s) | Test File |
|---|
Any other concerns about this one?
Any other concerns about this one?
any third party testing done (i.e. not the developer)?
@blueorangutan package
@hsato03 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 10815
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.
@blueorangutan package
@hsato03 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12222
@blueorangutan package
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 12653
@blueorangutan test
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests
[SF] Trillian test result (tid-12571) Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 53654 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8831-t12571-kvm-ol8.zip Smoke tests completed. 140 look OK, 1 have errors, 0 did not run Only failed and skipped tests results shown below:
| Test | Result | Time (s) | Test File |
|---|---|---|---|
| test_06_purge_expunged_vm_background_task | Failure |
402.26 | test_purge_expunged_vms.py |