From c4e27824666c5f588a2a9e2e4c920967e3be3445 Mon Sep 17 00:00:00 2001 From: Sanjay Tripathi Date: Fri, 19 Jun 2015 15:59:42 +0530 Subject: [PATCH] Recurring snapshot issue post upgrade from 3.0.7 to 4.5 --- .../cloudstack/storage/snapshot/SnapshotServiceImpl.java | 5 ++++- .../storage/snapshot/XenserverSnapshotStrategy.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java index 5a8afc68931a..4c76cda9fd61 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java @@ -237,7 +237,10 @@ private DataStore findSnapshotImageStore(SnapshotInfo snapshot) { // Note that DataStore information in parentSnapshot is for primary // data store here, we need to // find the image store where the parent snapshot backup is located - SnapshotDataStoreVO parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); + SnapshotDataStoreVO parentSnapshotOnBackupStore = null; + if (parentSnapshot != null) { + parentSnapshotOnBackupStore = _snapshotStoreDao.findBySnapshot(parentSnapshot.getId(), DataStoreRole.Image); + } if (parentSnapshotOnBackupStore == null) { return dataStoreMgr.getImageStore(snapshot.getDataCenterId()); } diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java index 51f75bd0c330..8ed77df9aaf8 100644 --- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java +++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java @@ -111,8 +111,9 @@ public SnapshotInfo backupSnapshot(SnapshotInfo snapshot) { boolean fullBackup = true; SnapshotDataStoreVO parentSnapshotOnBackupStore = snapshotStoreDao.findLatestSnapshotForVolume(snapshot.getVolumeId(), DataStoreRole.Image); + SnapshotDataStoreVO parentSnapshotOnPrimaryStore = snapshotStoreDao.findLatestSnapshotForVolume(snapshot.getVolumeId(), DataStoreRole.Primary); HypervisorType hypervisorType = snapshot.getBaseVolume().getHypervisorType(); - if (parentSnapshotOnBackupStore != null && hypervisorType == Hypervisor.HypervisorType.XenServer) { // CS does incremental backup only for XenServer + if (parentSnapshotOnPrimaryStore != null && parentSnapshotOnBackupStore != null && hypervisorType == Hypervisor.HypervisorType.XenServer) { // CS does incremental backup only for XenServer // In case of volume migration from one pool to other pool, CS should take full snapshot to avoid any issues with delta chain, // to check if this is a migrated volume, compare the current pool id of volume and store_id of oldest snapshot on primary for this volume.