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 <rohit.yadav@shapeblue.com>

* remove schedule on missing volume

---------

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2024-03-19 17:31:58 +05:30 committed by GitHub
parent 9d748f0837
commit 720407ba73
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {