Skip to content

alert messages restructure - #13775

Draft
DaanHoogland wants to merge 2 commits into
mainfrom
ghi7297-messages
Draft

alert messages restructure#13775
DaanHoogland wants to merge 2 commits into
mainfrom
ghi7297-messages

Conversation

@DaanHoogland

Copy link
Copy Markdown
Contributor

Description

This PR...

Fixes: #7297

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?

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.41%. Comparing base (4f11707) to head (3bfa044).

❗ There is a different number of reports uploaded between BASE (4f11707) and HEAD (3bfa044). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (4f11707) HEAD (3bfa044)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               main   #13775       +/-   ##
=============================================
- Coverage     19.65%    3.41%   -16.24%     
=============================================
  Files          6368      487     -5881     
  Lines        574881    41867   -533014     
  Branches      70351     7912    -62439     
=============================================
- Hits         112970     1429   -111541     
+ Misses       449639    40238   -409401     
+ Partials      12272      200    -12072     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests ?

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

☔ View full report in Codecov by Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Restructures several alert/log messages to be more consistent and information-rich, and introduces a shared formatter for host location descriptions (fixing CLOUDSTACK-7297).

Changes:

  • Added AlertFormatUtils.describeHostLocation(...) and reused it in HA/agent/orchestration alert call sites.
  • Updated many alerts/logs to include object context (e.g., host, domain, account) rather than only IDs/UUIDs.
  • Tweaked multiple failure/permission messages to improve operator readability.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
server/src/main/java/org/apache/cloudstack/outofbandmanagement/OutOfBandManagementServiceImpl.java Updates host degraded/removed debug message formatting.
server/src/main/java/org/apache/cloudstack/ha/provider/host/HAAbstractHostProvider.java Simplifies HA fencing/recovery alert subject/body to include host object.
server/src/main/java/org/apache/cloudstack/ca/CAManagerImpl.java Improves SSH provisioning error context by logging the host object.
server/src/main/java/com/cloud/vm/UserVmManagerImpl.java Reworks several VM/host dedication alert messages; adds account/domain lookups for richer output.
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java Updates snapshot limit alert to reference account object.
server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java Updates permission-denied exception messages to include domain object.
server/src/main/java/com/cloud/ha/KVMFencer.java Updates fencing failure alerts to include host object.
server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java Uses AlertFormatUtils for host location in HA alerts; improves VM-stopped alert host description.
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Makes several validation exceptions include full entity objects (domain/network offering).
server/src/main/java/com/cloud/alert/AlertManagerImpl.java Changes alert logging to structured logging with entity objects.
plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/provider/ScaleIOHostListener.java Updates ScaleIO host/pool alerts/logs to include host object.
plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java Updates ScaleIO disconnection checks/alerts to include host/pool objects.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/listener/OntapHostListener.java Improves Ontap attach-storage error messages by using host object.
plugins/storage/volume/datera/src/main/java/org/apache/cloudstack/storage/datastore/provider/DateraHostListener.java Improves Datera attach-storage alert message by using fetched host object.
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/datastore/provider/DefaultHostListener.java Improves default host connect failure message by including host object.
engine/storage/src/main/java/org/apache/cloudstack/storage/image/BaseImageStoreDriverImpl.java Updates upload/register/copy failure alerts to include object string.
engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/ScaleIOVMSnapshotStrategy.java Clarifies VM snapshot failure message to include snapshot object context.
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java Uses AlertFormatUtils to include host location in agent network-setup failure alert.
engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java Uses AlertFormatUtils for consistent host location strings in disconnect/alert-state messages.
engine/components-api/src/main/java/com/cloud/alert/AlertFormatUtils.java New shared helper for consistent host/zone/pod alert formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2865 to 2869
String subject = String.format("Failed to deploy Instance [%s]", vm);
String body = String.format("Failed to deploy [%s]%s. To troubleshoot, please check the logs with [logid:%s].",
vm,
hostId != null ? String.format(" on host [%s]", hostId) : "",
hostId != null ? String.format(" on host [%s]", host) : "",
ThreadContext.get("logcontextid"));
Comment on lines +7763 to +7769
Long srcAccountId = accountOfDedicatedHost(srcHost);
Long destAccountId = accountOfDedicatedHost(destHost);
if (!((srcAccountId == null) || (srcAccountId.equals(destAccountId)))) {
Account srcAccount = _accountDao.findById(srcAccountId);
Account destAccount = _accountDao.findById(destAccountId);
String msg = String.format("VM is being migrated from host %s explicitly dedicated to account %s to host %s explicitly dedicated to account %s",
srcHost, srcAccount, destHost, destAccount);
if (Domain.ROOT_DOMAIN == domainId) {
// no one can add limits on ROOT domain, disallow...
throw new PermissionDeniedException("Cannot update resource limit for ROOT domain " + domainId + ", permission denied");
throw new PermissionDeniedException("Cannot update resource limit for ROOT domain " + domain + ", permission denied");
if ((caller.getDomainId() == domainId) && caller.getType() == Account.Type.DOMAIN_ADMIN || caller.getType() == Account.Type.RESOURCE_DOMAIN_ADMIN) {
// if the admin is trying to update their own domain, disallow...
throw new PermissionDeniedException("Unable to update resource limit for domain " + domainId + ", permission denied");
throw new PermissionDeniedException("Unable to update resource limit for domain " + domain + ", permission denied");
Long podId = pod == null ? null : pod.getId();
long dcId = dataCenter == null ? 0L : dataCenter.getId();
logger.warn(String.format("alertType=[%s] dataCenterId=[%s] podId=[%s] clusterId=[%s] message=[%s].", alertType, dcId, podId, clusterId, subject));
logger.warn("alertType=[{}] dataCenter=[{}] pod=[{}] cluster=[{}] message=[{}].", alertType, dataCenter, pod, cluster, subject);
result.setResult(answer.getErrorString());
caller.complete(result);
String msg = "Failed to register template: " + obj.getUuid() + " with error: " + answer.getErrorString();
String msg = "Failed to register template: " + obj + " with error: " + answer.getErrorString();
result.setResult(answer.getErrorString());
caller.complete(result);
String msg = "Failed to upload volume: " + obj.getUuid() + " with error: " + answer.getErrorString();
String msg = "Failed to upload volume: " + obj + " with error: " + answer.getErrorString();
result.setResult(answer.getErrorString());
caller.complete(result);
String msg = "Failed to copy snapshot: " + obj.getUuid() + " with error: " + answer.getErrorString();
String msg = "Failed to copy snapshot: " + obj + " with error: " + answer.getErrorString();
Comment on lines +23 to +27
/**
* Shared formatting for the host/zone/pod description that recurs, independently
* hand-rolled and inconsistently worded (and occasionally mislabelled), across the
* HA and agent-management alert call sites. See CLOUDSTACK-7297.
*/
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.

Error messages and Alerts should include contextual and actionable information

2 participants