From 5fa6ff7fe4c18b8c9a1ef93ce280f09beb4f86cc Mon Sep 17 00:00:00 2001 From: Kris McQueen Date: Wed, 6 Oct 2010 18:24:19 -0700 Subject: [PATCH] Manual snapshots won't have an async job id, the job id gets set when the recurring snapshots get scheduled for execution. If the policy id is MANUAL, don't search for a job id. --- .../cloud/storage/dao/SnapshotScheduleDaoImpl.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java b/core/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java index d358976b46d..63363af80fc 100644 --- a/core/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java +++ b/core/src/com/cloud/storage/dao/SnapshotScheduleDaoImpl.java @@ -26,6 +26,7 @@ import java.util.List; import javax.ejb.Local; +import com.cloud.storage.Snapshot; import com.cloud.storage.SnapshotScheduleVO; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; @@ -86,12 +87,18 @@ public class SnapshotScheduleDaoImpl extends GenericDaoBase sc = createSearchCriteria(); + SearchCriteria.Op op = executing ? SearchCriteria.Op.NNULL : SearchCriteria.Op.NULL; sc.addAnd("volumeId", SearchCriteria.Op.EQ, volumeId); if (policyId != null) { sc.addAnd("policyId", SearchCriteria.Op.EQ, policyId); + if (policyId != Snapshot.MANUAL_POLICY_ID) { + // manual policies aren't scheduled by the snapshot poller, so don't look for the jobId here + sc.addAnd("asyncJobId", op); + } + } else { + sc.addAnd("asyncJobId", op); } - SearchCriteria.Op op = executing ? SearchCriteria.Op.NNULL : SearchCriteria.Op.NULL; - sc.addAnd("asyncJobId", op); + List snapshotSchedules = listBy(sc); // This will return only one schedule because of a DB uniqueness constraint. assert (snapshotSchedules.size() <= 1);