CLOUDSTACK-7264:NPE while creating scheduled/recurring snapshots for the

removed account with cleanup_needed=1.
This commit is contained in:
Min Chen 2014-08-08 09:42:05 -07:00
parent 2491630f51
commit d33278250d
1 changed files with 12 additions and 0 deletions

View File

@ -52,7 +52,9 @@ import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.SnapshotPolicyDao;
import com.cloud.storage.dao.SnapshotScheduleDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.dao.AccountDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.DateUtil.IntervalType;
import com.cloud.utils.NumbersUtil;
@ -84,6 +86,8 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
protected ConfigurationDao _configDao;
@Inject
protected ApiDispatcher _dispatcher;
@Inject
protected AccountDao _acctDao;
protected AsyncJobDispatcher _asyncDispatcher;
@ -235,6 +239,14 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
// this volume is not attached
continue;
}
Account volAcct = _acctDao.findById(volume.getAccountId());
if (volAcct == null || volAcct.getState() == Account.State.disabled) {
// this account has been removed, so don't trigger recurring snapshot
if (s_logger.isDebugEnabled()) {
s_logger.debug("Skip snapshot for volume " + volume.getUuid() + " since its account has been removed or disabled");
}
continue;
}
if (_snapshotPolicyDao.findById(policyId) == null) {
_snapshotScheduleDao.remove(snapshotToBeExecuted.getId());
}