mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-5395: mark snapshot_store_ref as destroyed in case of backup snapshot failed
This commit is contained in:
parent
90e01b1e10
commit
9ed4ab731f
|
|
@ -313,6 +313,10 @@ public class SnapshotServiceImpl implements SnapshotService {
|
|||
if (result.isFailed()) {
|
||||
try {
|
||||
destSnapshot.processEvent(Event.OperationFailed);
|
||||
//if backup snapshot failed, mark srcSnapshot in snapshot_store_ref as failed also
|
||||
srcSnapshot.processEvent(Event.DestroyRequested);
|
||||
srcSnapshot.processEvent(Event.OperationSuccessed);
|
||||
|
||||
srcSnapshot.processEvent(Snapshot.Event.OperationFailed);
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.debug("Failed to update state: " + e.toString());
|
||||
|
|
|
|||
|
|
@ -31,23 +31,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.PBD;
|
||||
import com.xensource.xenapi.Pool;
|
||||
import com.xensource.xenapi.SR;
|
||||
import com.xensource.xenapi.Types;
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VmPowerState;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VBD;
|
||||
import com.xensource.xenapi.VDI;
|
||||
import com.xensource.xenapi.VM;
|
||||
import com.xensource.xenapi.VMGuestMetrics;
|
||||
|
||||
import org.apache.cloudstack.storage.command.AttachAnswer;
|
||||
import org.apache.cloudstack.storage.command.AttachCommand;
|
||||
import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreAnswer;
|
||||
|
|
@ -66,6 +49,8 @@ import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
|
|||
import org.apache.cloudstack.storage.to.SnapshotObjectTO;
|
||||
import org.apache.cloudstack.storage.to.TemplateObjectTO;
|
||||
import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CreateStoragePoolCommand;
|
||||
|
|
@ -88,6 +73,19 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||
import com.cloud.utils.storage.encoding.DecodedDataObject;
|
||||
import com.cloud.utils.storage.encoding.DecodedDataStore;
|
||||
import com.cloud.utils.storage.encoding.Decoder;
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Host;
|
||||
import com.xensource.xenapi.PBD;
|
||||
import com.xensource.xenapi.Pool;
|
||||
import com.xensource.xenapi.SR;
|
||||
import com.xensource.xenapi.Types;
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VmPowerState;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VBD;
|
||||
import com.xensource.xenapi.VDI;
|
||||
import com.xensource.xenapi.VM;
|
||||
import com.xensource.xenapi.VMGuestMetrics;
|
||||
|
||||
public class XenServerStorageProcessor implements StorageProcessor {
|
||||
private static final Logger s_logger = Logger.getLogger(XenServerStorageProcessor.class);
|
||||
|
|
@ -488,11 +486,15 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
|||
Boolean isISCSI = IsISCSI(type);
|
||||
String snapshotParentUUID = getVhdParent(conn, srUUID, snapshotUUID, isISCSI);
|
||||
|
||||
String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
|
||||
if( snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
|
||||
// this is empty snapshot, remove it
|
||||
snapshot.destroy(conn);
|
||||
snapshotUUID = preSnapshotUUID;
|
||||
try {
|
||||
String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
|
||||
if( snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
|
||||
// this is empty snapshot, remove it
|
||||
snapshot.destroy(conn);
|
||||
snapshotUUID = preSnapshotUUID;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
s_logger.debug("Failed to get parent snapshot", e);
|
||||
}
|
||||
}
|
||||
SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
|
||||
|
|
@ -1328,6 +1330,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
s_logger.debug("Failed to get parent snapshots, take full snapshot", e);
|
||||
fullbackup = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue