mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-4907: handle create snapshot, when primary storage is not in up state
This commit is contained in:
parent
3855922378
commit
53eb469901
|
|
@ -176,6 +176,7 @@ public class CreateSnapshotCmd extends BaseAsyncCreateCmd {
|
|||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to create snapshot", e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public class SnapshotStateMachineManagerImpl implements SnapshotStateMachineMana
|
|||
stateMachine.addTransition(Snapshot.State.Copying, Event.OperationFailed, Snapshot.State.BackedUp);
|
||||
stateMachine.addTransition(Snapshot.State.Destroying, Event.OperationSucceeded, Snapshot.State.Destroyed);
|
||||
stateMachine.addTransition(Snapshot.State.Destroying, Event.OperationFailed, State.BackedUp);
|
||||
stateMachine.addTransition(Snapshot.State.Allocated, Event.OperationFailed, State.Error);
|
||||
|
||||
stateMachine.registerListener(new SnapshotStateListener());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.apache.cloudstack.storage.snapshot;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.*;
|
||||
import com.cloud.utils.db.DB;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.*;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
|
||||
|
|
@ -32,9 +32,6 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
|
|
@ -255,6 +252,11 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
|
|||
|
||||
try {
|
||||
VolumeInfo volumeInfo = snapshot.getBaseVolume();
|
||||
StoragePool store = (StoragePool)volumeInfo.getDataStore();
|
||||
if (store != null && store.getStatus() != StoragePoolStatus.Up) {
|
||||
snapshot.processEvent(Event.OperationFailed);
|
||||
throw new CloudRuntimeException("store is not in up state");
|
||||
}
|
||||
volumeInfo.stateTransit(Volume.Event.SnapshotRequested);
|
||||
SnapshotResult result = null;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1303,11 +1303,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||
|
||||
@Override
|
||||
public SnapshotInfo takeSnapshot(VolumeInfo volume) {
|
||||
PrimaryDataStore store = (PrimaryDataStore)volume.getDataStore();
|
||||
|
||||
if (store.getStatus() != StoragePoolStatus.Up) {
|
||||
throw new CloudRuntimeException("store is not in up state");
|
||||
}
|
||||
|
||||
|
||||
SnapshotInfo snapshot = null;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.storage.*;
|
||||
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
|
||||
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
|
||||
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
|
||||
|
|
@ -77,21 +78,7 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
|||
import com.cloud.projects.Project.ListProjectResourcesCriteria;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.storage.CreateSnapshotPayload;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
import com.cloud.storage.SnapshotPolicyVO;
|
||||
import com.cloud.storage.SnapshotScheduleVO;
|
||||
import com.cloud.storage.SnapshotVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeManager;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.SnapshotPolicyDao;
|
||||
|
|
@ -1000,6 +987,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
|||
@Override
|
||||
@DB
|
||||
public SnapshotInfo takeSnapshot(VolumeInfo volume) throws ResourceAllocationException {
|
||||
|
||||
CreateSnapshotPayload payload = (CreateSnapshotPayload)volume.getpayload();
|
||||
Long snapshotId = payload.getSnapshotId();
|
||||
Account snapshotOwner = payload.getAccount();
|
||||
|
|
|
|||
Loading…
Reference in New Issue