From 720407ba73796d1bbbd56b3f65a5567143036c3e Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 19 Mar 2024 17:31:58 +0530 Subject: [PATCH 1/2] 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 * remove schedule on missing volume --------- Signed-off-by: Rohit Yadav --- .../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) { From 8c62365dbb140feb8ab350724b4567f5ed449454 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Tue, 19 Mar 2024 18:45:24 +0100 Subject: [PATCH 2/2] VPC VR: fix empty iptables if there is no vpc tier (#8787) --- .../debian/opt/cloud/bin/setup/postinit.sh | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/setup/postinit.sh b/systemvm/debian/opt/cloud/bin/setup/postinit.sh index ba5c394d9f2..6bb3f6bd097 100755 --- a/systemvm/debian/opt/cloud/bin/setup/postinit.sh +++ b/systemvm/debian/opt/cloud/bin/setup/postinit.sh @@ -26,6 +26,19 @@ log_it() { # Restart journald for setting changes to apply systemctl restart systemd-journald +# Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist +ipv4="/etc/iptables/rules.v4" +if [ -e $ipv4 ] +then + iptables-restore < $ipv4 +fi + +ipv6="/etc/iptables/rules.v6" +if [ -e $ipv6 ] +then + ip6tables-restore < $ipv6 +fi + CMDLINE=/var/cache/cloud/cmdline TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE) if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ] @@ -52,17 +65,4 @@ do systemctl disable --now --no-block $svc done -# Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist -ipv4="/etc/iptables/rules.v4" -if [ -e $ipv4 ] -then - iptables-restore < $ipv4 -fi - -ipv6="/etc/iptables/rules.v6" -if [ -e $ipv6 ] -then - ip6tables-restore < $ipv6 -fi - date > /var/cache/cloud/boot_up_done