CLOUDSTACK-5395: mark snapshot_store_ref as destroyed in case of backup snapshot failed

Conflicts:

	plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java
This commit is contained in:
Edison Su 2014-03-27 15:37:51 -07:00 committed by Anthony Xu
parent a72222dd46
commit e656201fee
2 changed files with 29 additions and 18 deletions

View File

@ -302,6 +302,10 @@ public class SnapshotServiceImpl implements SnapshotService {
if (result.isFailed()) { if (result.isFailed()) {
try { try {
destSnapshot.processEvent(Event.OperationFailed); 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); srcSnapshot.processEvent(Snapshot.Event.OperationFailed);
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.debug("Failed to update state: " + e.toString()); s_logger.debug("Failed to update state: " + e.toString());

View File

@ -30,19 +30,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import com.xensource.xenapi.Connection; import javax.ws.rs.HEAD;
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.AttachAnswer;
import org.apache.cloudstack.storage.command.AttachCommand; import org.apache.cloudstack.storage.command.AttachCommand;
@ -87,6 +75,19 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.storage.encoding.DecodedDataObject; import com.cloud.utils.storage.encoding.DecodedDataObject;
import com.cloud.utils.storage.encoding.DecodedDataStore; import com.cloud.utils.storage.encoding.DecodedDataStore;
import com.cloud.utils.storage.encoding.Decoder; 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 { public class XenServerStorageProcessor implements StorageProcessor {
private static final Logger s_logger = Logger.getLogger(XenServerStorageProcessor.class); private static final Logger s_logger = Logger.getLogger(XenServerStorageProcessor.class);
@ -475,11 +476,15 @@ public class XenServerStorageProcessor implements StorageProcessor {
Boolean isISCSI = IsISCSI(type); Boolean isISCSI = IsISCSI(type);
String snapshotParentUUID = getVhdParent(conn, srUUID, snapshotUUID, isISCSI); String snapshotParentUUID = getVhdParent(conn, srUUID, snapshotUUID, isISCSI);
String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI); try {
if (snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) { String preSnapshotParentUUID = getVhdParent(conn, srUUID, preSnapshotUUID, isISCSI);
// this is empty snapshot, remove it if( snapshotParentUUID != null && snapshotParentUUID.equals(preSnapshotParentUUID)) {
snapshot.destroy(conn); // this is empty snapshot, remove it
snapshotUUID = preSnapshotUUID; snapshot.destroy(conn);
snapshotUUID = preSnapshotUUID;
}
} catch(Exception e) {
s_logger.debug("Failed to get parent snapshot", e);
} }
} }
SnapshotObjectTO newSnapshot = new SnapshotObjectTO(); SnapshotObjectTO newSnapshot = new SnapshotObjectTO();
@ -1368,6 +1373,8 @@ public class XenServerStorageProcessor implements StorageProcessor {
} }
} }
} catch (Exception e) { } catch (Exception e) {
s_logger.debug("Failed to get parent snapshots, take full snapshot", e);
fullbackup = true;
} }
} }