Skip to content

Conversation

shwstppr
Copy link
Contributor

Description

Fixes #6613

Introduces support for configuring additional alert types that can be published repeatedly, beyond the default set.

Operators can now use the dynamic configuration alert.allowed.repetitive.types to specify a comma-separated list of alert type names that should be allowed for repetitive publication.

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)
  • 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
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Fixes apache#6613

Introduces support for configuring additional alert types that can be published repeatedly, beyond the default set.

Operators can now use the dynamic configuration `alert.allowed.repetitive.types` to specify a comma-separated list of alert type names that should be allowed for repetitive publication.

Signed-off-by: Abhishek Kumar <[email protected]>
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 83.95062% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.50%. Comparing base (a60c8ca) to head (0299cfc).
⚠️ Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
...rc/main/java/com/cloud/alert/AlertManagerImpl.java 82.75% 2 Missing and 3 partials ⚠️
...java/org/apache/cloudstack/alert/AlertService.java 93.47% 3 Missing ⚠️
...che/cloudstack/api/response/AlertTypeResponse.java 0.00% 3 Missing ⚠️
.../api/command/admin/resource/ListAlertTypesCmd.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11325      +/-   ##
============================================
+ Coverage     17.35%   17.50%   +0.15%     
- Complexity    15189    15481     +292     
============================================
  Files          5883     5885       +2     
  Lines        524514   535880   +11366     
  Branches      64007    68731    +4724     
============================================
+ Hits          91013    93791    +2778     
- Misses       423216   431552    +8336     
- Partials      10285    10537     +252     
Flag Coverage Δ
uitests 3.86% <ø> (+0.22%) ⬆️
unittests 18.52% <83.95%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces configurable repetitive alerts functionality, allowing operators to specify additional alert types that can be published repeatedly beyond the default set. The enhancement replaces the hardcoded list of repetitive alert types with a dynamic configuration system.

Key changes:

  • Adds a new configuration parameter alert.allowed.repetitive.types for specifying comma-separated alert type names
  • Implements dynamic configuration updates through message bus listening
  • Updates the alert type system to include repetition capability information in API responses

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/src/main/java/com/cloud/alert/AlertManagerImpl.java Replaces hardcoded repetitive alert list with dynamic configuration and message bus listener
engine/components-api/src/main/java/com/cloud/alert/AlertManager.java Adds new configuration key for allowed repetitive alert types
api/src/main/java/org/apache/cloudstack/api/response/AlertTypeResponse.java Adds repetition allowed field to alert type API response
api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListAlertTypesCmd.java Updates command to include repetition information in responses
api/src/main/java/org/apache/cloudstack/api/ApiConstants.java Adds API constant for repetition allowed field
api/src/main/java/org/apache/cloudstack/alert/AlertService.java Updates AlertType class with repetition capability and name-based lookup

Comment on lines +80 to +81
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple AlertType constants are using the same type value (32). ALERT_TYPE_VM_SNAPSHOT, ALERT_TYPE_VR_PUBLIC_IFACE_MTU, and ALERT_TYPE_VR_PRIVATE_IFACE_MTU all use (short)32, which will cause conflicts in alert type identification.

Suggested change
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)34, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)35, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to mitigate these bogus remarks we might want to extract these magin values into constants!?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix added here, #11350
I'm not sure how it would affect but it definitely needs a better way to assign values. Separate change though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant magic numbers, will comment there.

Comment on lines +80 to +81
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This AlertType uses the same type value (32) as ALERT_TYPE_VM_SNAPSHOT and ALERT_TYPE_VR_PUBLIC_IFACE_MTU. Each AlertType should have a unique type identifier.

Suggested change
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)34, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)35, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);

Copilot uses AI. Check for mistakes.

@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr 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.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14484

Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

Signed-off-by: Abhishek Kumar <[email protected]>
@@ -108,9 +117,13 @@ public static AlertType generateAlert(short type, String name) {
if (defaultAlert != null && !defaultAlert.getName().equalsIgnoreCase(name)) {
throw new InvalidParameterValueException("There is a default alert having type " + type + " and name " + defaultAlert.getName());
} else {
return new AlertType(type, name, false);
return new AlertType(type, name, false, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so custom alerts are never allowed to be repeated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes will allow that if operator has added the type name in the config,

image

Comment on lines +80 to +81
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true, false);
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to mitigate these bogus remarks we might want to extract these magin values into constants!?

Signed-off-by: Abhishek Kumar <[email protected]>
@shwstppr shwstppr marked this pull request as ready for review August 5, 2025 10:57
@shwstppr shwstppr closed this Aug 5, 2025
@shwstppr shwstppr reopened this Aug 5, 2025
@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 5, 2025

@blueorangutan package

1 similar comment
@DaanHoogland
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

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

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14560

@shwstppr
Copy link
Contributor Author

shwstppr commented Aug 8, 2025

@blueorangutan test

@blueorangutan
Copy link

@shwstppr a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14049)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 51469 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11325-t14049-kvm-ol8.zip
Smoke tests completed. 146 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improvement on administrator alerts
3 participants