Skip to content

deal with excessive attempts on failing snapshots - #13743

Open
DaanHoogland wants to merge 1 commit into
mainfrom
ghi13454-recurringFailingSnapshots
Open

deal with excessive attempts on failing snapshots#13743
DaanHoogland wants to merge 1 commit into
mainfrom
ghi13454-recurringFailingSnapshots

Conversation

@DaanHoogland

@DaanHoogland DaanHoogland commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

This PR...

Fixes: #13454
Fixes: #6827

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?

Copilot AI review requested due to automatic review settings July 29, 2026 09:48
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.77372% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.66%. Comparing base (e1cf0f3) to head (de2aee2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../cloud/storage/snapshot/SnapshotSchedulerImpl.java 67.52% 29 Missing and 9 partials ⚠️
...rc/main/java/com/cloud/event/dao/EventDaoImpl.java 0.00% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13743      +/-   ##
============================================
+ Coverage     19.64%   19.66%   +0.01%     
- Complexity    19796    19808      +12     
============================================
  Files          6368     6368              
  Lines        575119   575017     -102     
  Branches      70382    70371      -11     
============================================
+ Hits         112994   113059      +65     
+ Misses       449839   449675     -164     
+ Partials      12286    12283       -3     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 20.93% <62.77%> (+0.01%) ⬆️

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.

This PR adds logic to reduce excessive retry attempts for failing recurring snapshots by tracking outcomes via event history, applying configurable retry/backoff behavior for dispatch failures, and optionally skipping snapshots when a VM hasn’t been running since the last snapshot.

Changes:

  • Add configurable max-failure and retry-interval handling for recurring snapshot dispatch failures (and log outcomes as events for consecutive-failure counting).
  • Introduce optional “skip snapshot if VM not running since last snapshot” behavior plus a new SNAPSHOT.SKIPPED event type.
  • Add DAO support to query recent events per resource, and add unit tests covering the new behaviors.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java Adds failure counting, scoped config resolution, dispatch failure handling with backoff/give-up, and unchanged-volume skip logic.
server/src/test/java/com/cloud/storage/snapshot/SnapshotSchedulerImplTest.java Adds unit tests for consecutive failure counting, scoped config fallback, dispatch failure behavior, and skip logic.
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java Registers new snapshot-related config keys.
server/src/main/java/com/cloud/storage/snapshot/SnapshotManager.java Defines new scoped config keys for recurring snapshot failure handling and skip behavior.
engine/schema/src/main/java/com/cloud/event/dao/EventDaoImpl.java Implements querying latest events per resource for failure counting.
engine/schema/src/main/java/com/cloud/event/dao/EventDao.java Adds DAO API for latest-events-by-resource lookup.
api/src/main/java/com/cloud/event/EventTypes.java Adds EVENT_SNAPSHOT_SKIPPED constant and registers it for entity-event details.

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

Comment on lines +249 to +254
if (maxFailures > 0 && totalFailures >= maxFailures) {
logger.warn("Snapshot schedule [{}] for volume [{}] has failed [{}] consecutive times.", snapshotSchedule, volume, totalFailures);
ActionEventUtils.onCreatedActionEvent(User.UID_SYSTEM, volume.getAccountId(), EventVO.LEVEL_WARN, EventTypes.EVENT_SNAPSHOT_CREATE, true,
String.format("Recurring snapshot for volume [%s] has failed %d consecutive times.", volume, totalFailures),
volume.getId(), ApiCommandResourceType.Volume.toString());
}
Comment on lines +115 to +123
@Override
public List<EventVO> listLatestEventsByResource(long resourceId, String resourceType, String type, int limit) {
SearchCriteria<EventVO> sc = LatestEventsByResourceSearch.create();
sc.setParameters("resourceId", resourceId);
sc.setParameters("resourceType", resourceType);
sc.setParameters("type", type);
Filter filter = new Filter(EventVO.class, "createDate", false, 0L, (long) limit);
return listBy(sc, filter);
}
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔴 Test Coverage Grade: D — Marginal

Metric Value
Line coverage 24.52%
Branch coverage 18.68%

Grade Scale

Grade Line Coverage Meaning
🟢 A ≥ 80% Excellent - this code sleeps well at night 😴
🟡 B 60-79% Good - almost there, don't stop now 😉
🟠 C 40-59% Acceptable - your code is wearing a seatbelt, but no airbags 😬
🔴 D 20-39% Marginal - boldly shipping where no test has gone before 🖖
⛔ F < 20% Failing - tests? what tests? 🔥

Branch coverage is shown as a secondary signal. Grade is determined by line coverage.
View full Actions run

@DaanHoogland
DaanHoogland marked this pull request as ready for review July 29, 2026 16:05
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.

Add settings retry attempts and interval retry attempts for recurring snapshots Zero size recurring snapshots piling up after server is shutdown

2 participants