diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index bde092d0483..ca47e3f8bf1 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3929,12 +3929,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR } finally { sshConnection.close(); } - try { - // wait 2 seconds before call plugin - Thread.sleep(2000); - } catch (final InterruptedException ex) { - } if (!setIptables()) { s_logger.warn("set xenserver Iptable failed"); } diff --git a/core/src/com/cloud/vm/State.java b/core/src/com/cloud/vm/State.java index f0cc88c9509..c8bbb140f10 100644 --- a/core/src/com/cloud/vm/State.java +++ b/core/src/com/cloud/vm/State.java @@ -21,6 +21,7 @@ package com.cloud.vm; import java.util.List; import com.cloud.utils.fsm.StateMachine; +import com.cloud.vm.VirtualMachine.Event; public enum State { Creating(true), @@ -95,5 +96,6 @@ public enum State { s_fsm.addTransition(State.Stopping, VirtualMachine.Event.StopRequested, State.Stopping); s_fsm.addTransition(State.Expunging, VirtualMachine.Event.OperationFailed, State.Expunging); s_fsm.addTransition(State.Expunging, VirtualMachine.Event.ExpungeOperation, State.Expunging); + s_fsm.addTransition(State.Error, VirtualMachine.Event.ExpungeOperation, State.Expunging); } } diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index f2d92ac5350..6c2d0cdca7c 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -910,10 +910,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory { Long dcId = host.getDataCenterId(); ReadyCommand ready = new ReadyCommand(dcId); - Answer answer = easySend(hostId, ready); + Answer answer = easySend(hostId, ready); if (answer == null) { + // this is tricky part for secondary storage + // make it as disconnected, wait for secondary storage VM to be up + // return the attache instead of null, even it is disconnectede handleDisconnect(attache, Event.AgentDisconnected, false); - return null; } _hostDao.updateStatus(host, Event.Ready, _nodeId); diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java index 0debbc65135..4e9eb137894 100644 --- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java +++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java @@ -382,41 +382,46 @@ public class SnapshotManagerImpl implements SnapshotManager { txn = Transaction.currentTxn(); txn.start(); - // Update the snapshot in the database - if ((answer != null) && answer.getResult()) { - // The snapshot was successfully created - if( preSnapshotPath != null && preSnapshotPath == answer.getSnapshotPath() ){ - //empty snapshot - s_logger.debug("CreateSnapshot: this is empty snapshot, remove it "); + try { + // Update the snapshot in the database + if ((answer != null) && answer.getResult()) { + // The snapshot was successfully created + if (preSnapshotPath != null && preSnapshotPath == answer.getSnapshotPath()) { + // empty snapshot + s_logger.debug("CreateSnapshot: this is empty snapshot, remove it "); + // delete from the snapshots table + _snapshotDao.delete(id); + throw new CloudRuntimeException( + " There is no change since last snapshot, please use last snapshot " + preSnapshotPath); + + } else { + createdSnapshot = updateDBOnCreate(id, answer.getSnapshotPath()); + } + } else { + String msg = "createSnapshotCommand returns null"; + if (answer != null) { + msg = answer.getDetails(); + s_logger.error(msg); + } // delete from the snapshots table _snapshotDao.delete(id); - throw new CloudRuntimeException(" There is no change since last snapshot, please use last snapshot " + preSnapshotPath); - - } else { - createdSnapshot = updateDBOnCreate(id, answer.getSnapshotPath()); + throw new CloudRuntimeException(" CreateSnapshot failed due to " + msg); } - } else { - if (answer != null) { - s_logger.error(answer.getDetails()); + + // Update async status after snapshot creation and before backup + if (asyncExecutor != null) { + AsyncJobVO job = asyncExecutor.getJob(); + + if (s_logger.isDebugEnabled()) + s_logger.debug("CreateSnapshot created a new instance " + id + ", update async job-" + job.getId() + + " progress status"); + + _asyncMgr.updateAsyncJobAttachment(job.getId(), "snapshot", id); + _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, id); } - // The snapshot was not successfully created - createdSnapshot = _snapshotDao.findById(id); - // delete from the snapshots table - _snapshotDao.delete(id); - + } finally { + txn.commit(); } - - // Update async status after snapshot creation and before backup - if(asyncExecutor != null) { - AsyncJobVO job = asyncExecutor.getJob(); - - if(s_logger.isDebugEnabled()) - s_logger.debug("CreateSnapshot created a new instance " + id + ", update async job-" + job.getId() + " progress status"); - - _asyncMgr.updateAsyncJobAttachment(job.getId(), "snapshot", id); - _asyncMgr.updateAsyncJobStatus(job.getId(), BaseCmd.PROGRESS_INSTANCE_CREATED, id); - } - txn.commit(); return createdSnapshot; } diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index f4ec7d530e7..db15b644f50 100644 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -633,6 +633,9 @@ public class TemplateManagerImpl implements TemplateManager { // Check if there are any snapshots for the template in the template host ref's zone List volumes = _volumeDao.findByTemplateAndZone(templateId, zoneId); + if( volumes.size() > 0 ) { + return false; + } for (VolumeVO volume : volumes) { List snapshots = _snapshotDao.listByVolumeId(volume.getId()); if (!snapshots.isEmpty()) {