You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by jo...@apache.org on 2024/03/19 12:02:04 UTC

(cloudstack) branch 4.18 updated: snapshot: don't schedule next snapshot job for a removed volume (#8735)

This is an automated email from the ASF dual-hosted git repository.

joao pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.18 by this push:
     new 720407ba737 snapshot: don't schedule next snapshot job for a removed volume (#8735)
720407ba737 is described below

commit 720407ba73796d1bbbd56b3f65a5567143036c3e
Author: Rohit Yadav <ro...@shapeblue.com>
AuthorDate: Tue Mar 19 17:31:58 2024 +0530

    snapshot: don't schedule next snapshot job for a removed volume (#8735)
    
    * snapshot: don't schedule next snapshot job for a removed volume
    
    When management server starts, it starts the snapshot scheduler. In case
    there is a volume snapshot policy which exists for a volume which does
    not exist, it can cause SQL constraint issue and cause the management
    server to break from starting its various components and cause HTTP 503
    error.
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
    
    * remove schedule on missing volume
    
    ---------
    
    Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
---
 .../java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java     | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java b/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
index a9c402c86be..d4fe08397f9 100644
--- a/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
+++ b/server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java
@@ -378,6 +378,13 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
         if (policyId == Snapshot.MANUAL_POLICY_ID) {
             return null;
         }
+
+        if (_volsDao.findById(policy.getVolumeId()) == null) {
+            s_logger.warn("Found snapshot policy ID: " + policyId + " for volume ID: " + policy.getVolumeId() + " that does not exist or has been removed");
+            removeSchedule(policy.getVolumeId(), policy.getId());
+            return null;
+        }
+
         final Date nextSnapshotTimestamp = getNextScheduledTime(policyId, _currentTimestamp);
         SnapshotScheduleVO spstSchedVO = _snapshotScheduleDao.findOneByVolumePolicy(policy.getVolumeId(), policy.getId());
         if (spstSchedVO == null) {