Skip to content

Commit 2f2811c

Browse files
yadvrdhslove
authored andcommitted
snapshot: don't schedule next snapshot job for a removed volume (apache#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 <rohit.yadav@shapeblue.com> * remove schedule on missing volume --------- Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 82123d3 commit 2f2811c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

server/src/main/java/com/cloud/storage/snapshot/SnapshotSchedulerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ public Date scheduleNextSnapshotJob(final SnapshotPolicyVO policy) {
415415
if (policyId == Snapshot.MANUAL_POLICY_ID) {
416416
return null;
417417
}
418+
419+
if (_volsDao.findById(policy.getVolumeId()) == null) {
420+
s_logger.warn("Found snapshot policy ID: " + policyId + " for volume ID: " + policy.getVolumeId() + " that does not exist or has been removed");
421+
removeSchedule(policy.getVolumeId(), policy.getId());
422+
return null;
423+
}
424+
418425
final Date nextSnapshotTimestamp = getNextScheduledTime(policyId, _currentTimestamp);
419426
SnapshotScheduleVO spstSchedVO = _snapshotScheduleDao.findOneByVolumePolicy(policy.getVolumeId(), policy.getId());
420427
if (spstSchedVO == null) {

0 commit comments

Comments
 (0)