cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/master to 67113ff
Date Thu, 20 Nov 2014 00:08:24 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master c05cda0d2 -> 67113ff0b


CLOUDSTACK-7946:
remove leftover state in volume and snapshot table in case of mgt server
shutdown during storage operation.
Reviewed-by: Min


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/67113ff0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/67113ff0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/67113ff0

Branch: refs/heads/master
Commit: 67113ff0b28f05ece2a76e11bcc136bed648e7c6
Parents: c05cda0
Author: Edison Su <sudison@gmail.com>
Authored: Tue Nov 11 16:02:20 2014 -0800
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Nov 19 16:06:37 2014 -0800

----------------------------------------------------------------------
 .../service/VolumeOrchestrationService.java     |  4 +-
 .../subsystem/api/storage/SnapshotService.java  |  2 +
 .../src/com/cloud/vm/VmWorkAttachVolume.java    | 38 ++++++++++
 .../src/com/cloud/vm/VmWorkDetachVolume.java    | 32 ++++++++
 .../src/com/cloud/vm/VmWorkMigrateVolume.java   | 44 +++++++++++
 .../src/com/cloud/vm/VmWorkResizeVolume.java    | 71 ++++++++++++++++++
 .../com/cloud/vm/VmWorkTakeVolumeSnapshot.java  | 52 +++++++++++++
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  1 +
 .../orchestration/VolumeOrchestrator.java       | 77 +++++++++++++++++++-
 .../src/com/cloud/storage/dao/VolumeDao.java    |  2 +
 .../com/cloud/storage/dao/VolumeDaoImpl.java    |  9 +++
 .../storage/snapshot/SnapshotServiceImpl.java   | 22 ++++++
 .../com/cloud/cluster/ClusterManagerImpl.java   |  4 +-
 .../framework/jobs/AsyncJobManager.java         |  2 +
 .../framework/jobs/dao/AsyncJobDao.java         |  2 +
 .../framework/jobs/dao/AsyncJobDaoImpl.java     | 17 +++++
 .../jobs/impl/AsyncJobManagerImpl.java          |  5 ++
 .../com/cloud/storage/VmWorkAttachVolume.java   | 40 ----------
 .../com/cloud/storage/VmWorkDetachVolume.java   | 34 ---------
 .../com/cloud/storage/VmWorkMigrateVolume.java  | 46 ------------
 .../com/cloud/storage/VmWorkResizeVolume.java   | 73 -------------------
 .../cloud/storage/VmWorkTakeVolumeSnapshot.java | 54 --------------
 22 files changed, 379 insertions(+), 252 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
index 281de92..1f198a2 100644
--- a/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/orchestration/service/VolumeOrchestrationService.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.config.ConfigKey;
 
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.dc.DataCenter;
@@ -46,7 +47,6 @@ import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.vm.DiskProfile;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
-import org.apache.cloudstack.framework.config.ConfigKey;
 
 /**
  * VolumeOrchestrationService is a PURE orchestration service on CloudStack
@@ -86,6 +86,8 @@ public interface VolumeOrchestrationService {
 
     Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException;
 
+    void cleanupStorageJobs();
+
     void destroyVolume(Volume volume);
 
     DiskProfile allocateRawVolume(Type type, String name, DiskOffering offering, Long size,
Long minIops, Long maxIops, VirtualMachine vm, VirtualMachineTemplate template, Account owner);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
index 000b9ec..4edeb55 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotService.java
@@ -27,4 +27,6 @@ public interface SnapshotService {
     boolean revertSnapshot(Long snapshotId);
 
     void syncVolumeSnapshotsToRegionStore(long volumeId, DataStore store);
+
+    void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/components-api/src/com/cloud/vm/VmWorkAttachVolume.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VmWorkAttachVolume.java b/engine/components-api/src/com/cloud/vm/VmWorkAttachVolume.java
new file mode 100644
index 0000000..2d2fefb
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VmWorkAttachVolume.java
@@ -0,0 +1,38 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+public class VmWorkAttachVolume extends VmWork {
+    private static final long serialVersionUID = 553291814854451740L;
+
+    private Long volumeId;
+    private Long deviceId;
+
+    public VmWorkAttachVolume(long userId, long accountId, long vmId, String handlerName,
Long volumeId, Long deviceId) {
+        super(userId, accountId, vmId, handlerName);
+        this.volumeId = volumeId;
+        this.deviceId = deviceId;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+
+    public Long getDeviceId() {
+        return deviceId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/components-api/src/com/cloud/vm/VmWorkDetachVolume.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VmWorkDetachVolume.java b/engine/components-api/src/com/cloud/vm/VmWorkDetachVolume.java
new file mode 100644
index 0000000..91831e4
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VmWorkDetachVolume.java
@@ -0,0 +1,32 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+public class VmWorkDetachVolume extends VmWork {
+    private static final long serialVersionUID = -8722243207385263101L;
+
+    private Long volumeId;
+
+    public VmWorkDetachVolume(long userId, long accountId, long vmId, String handlerName,
Long volumeId) {
+        super(userId, accountId, vmId, handlerName);
+        this.volumeId = volumeId;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/components-api/src/com/cloud/vm/VmWorkMigrateVolume.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VmWorkMigrateVolume.java b/engine/components-api/src/com/cloud/vm/VmWorkMigrateVolume.java
new file mode 100644
index 0000000..994b492
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VmWorkMigrateVolume.java
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+public class VmWorkMigrateVolume extends VmWork {
+    private static final long serialVersionUID = -565778516928408602L;
+
+    private long volumeId;
+    private long destPoolId;
+    private boolean liveMigrate;
+
+    public VmWorkMigrateVolume(long userId, long accountId, long vmId, String handlerName,
long volumeId, long destPoolId, boolean liveMigrate) {
+        super(userId, accountId, vmId, handlerName);
+        this.volumeId = volumeId;
+        this.destPoolId = destPoolId;
+        this.liveMigrate = liveMigrate;
+    }
+
+    public long getVolumeId() {
+        return volumeId;
+    }
+
+    public long getDestPoolId() {
+        return destPoolId;
+    }
+
+    public boolean isLiveMigrate() {
+        return liveMigrate;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/components-api/src/com/cloud/vm/VmWorkResizeVolume.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VmWorkResizeVolume.java b/engine/components-api/src/com/cloud/vm/VmWorkResizeVolume.java
new file mode 100644
index 0000000..d269112
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VmWorkResizeVolume.java
@@ -0,0 +1,71 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+public class VmWorkResizeVolume extends VmWork {
+    private static final long serialVersionUID = 6112366316907642498L;
+
+    private long volumeId;
+    private long currentSize;
+    private long newSize;
+    private Long newMinIops;
+    private Long newMaxIops;
+    private Long newServiceOfferingId;
+    private boolean shrinkOk;
+
+    public VmWorkResizeVolume(long userId, long accountId, long vmId, String handlerName,
+            long volumeId, long currentSize, long newSize, Long newMinIops, Long newMaxIops,
Long newServiceOfferingId, boolean shrinkOk) {
+
+        super(userId, accountId, vmId, handlerName);
+
+        this.volumeId = volumeId;
+        this.currentSize = currentSize;
+        this.newSize = newSize;
+        this.newMinIops = newMinIops;
+        this.newMaxIops = newMaxIops;
+        this.newServiceOfferingId = newServiceOfferingId;
+        this.shrinkOk = shrinkOk;
+    }
+
+    public long getVolumeId() {
+        return volumeId;
+    }
+
+    public long getCurrentSize() {
+        return currentSize;
+    }
+
+    public long getNewSize() {
+        return newSize;
+    }
+
+    public Long getNewMinIops() {
+        return newMinIops;
+    }
+
+    public Long getNewMaxIops() {
+        return newMaxIops;
+    }
+
+    public Long getNewServiceOfferingId() {
+        return newServiceOfferingId;
+    }
+
+    public boolean isShrinkOk() {
+        return shrinkOk;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/components-api/src/com/cloud/vm/VmWorkTakeVolumeSnapshot.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/vm/VmWorkTakeVolumeSnapshot.java b/engine/components-api/src/com/cloud/vm/VmWorkTakeVolumeSnapshot.java
new file mode 100644
index 0000000..3160be1
--- /dev/null
+++ b/engine/components-api/src/com/cloud/vm/VmWorkTakeVolumeSnapshot.java
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.vm;
+
+public class VmWorkTakeVolumeSnapshot extends VmWork {
+
+    private static final long serialVersionUID = 341816293003023823L;
+
+    private Long volumeId;
+    private Long policyId;
+    private Long snapshotId;
+    private boolean quiesceVm;
+
+    public VmWorkTakeVolumeSnapshot(long userId, long accountId, long vmId, String handlerName,
+            Long volumeId, Long policyId, Long snapshotId, boolean quiesceVm) {
+        super(userId, accountId, vmId, handlerName);
+        this.volumeId = volumeId;
+        this.policyId = policyId;
+        this.snapshotId = snapshotId;
+        this.quiesceVm = quiesceVm;
+    }
+
+    public Long getVolumeId() {
+        return volumeId;
+    }
+
+    public Long getPolicyId() {
+        return policyId;
+    }
+
+    public Long getSnapshotId() {
+        return snapshotId;
+    }
+
+    public boolean isQuiesceVm() {
+        return quiesceVm;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index dc6ad3f..fa8b7b6 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -566,6 +566,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
         _executor.scheduleAtFixedRate(new TransitionTask(),  VmOpCleanupInterval.value(),
VmOpCleanupInterval.value(), TimeUnit.SECONDS);
         cancelWorkItems(_nodeId);
 
+        volumeMgr.cleanupStorageJobs();
         // cleanup left over place holder works
         _workJobDao.expungeLeftoverWorkJobs(ManagementServerNode.getManagementServerId());
         return true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
index 63d967b..515d5ec 100644
--- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
+++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
@@ -54,6 +54,8 @@ import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.jobs.AsyncJobManager;
+import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 import org.apache.cloudstack.storage.command.CommandResult;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
@@ -64,6 +66,7 @@ import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.agent.manager.allocator.PodAllocator;
+import com.cloud.cluster.ClusterManager;
 import com.cloud.configuration.Resource.ResourceType;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.Pod;
@@ -117,6 +120,10 @@ import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.VirtualMachineProfileImpl;
+import com.cloud.vm.VmWorkAttachVolume;
+import com.cloud.vm.VmWorkMigrateVolume;
+import com.cloud.vm.VmWorkSerializer;
+import com.cloud.vm.VmWorkTakeVolumeSnapshot;
 import com.cloud.vm.dao.UserVmDao;
 
 public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrationService,
Configurable {
@@ -156,6 +163,10 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
     SnapshotService _snapshotSrv;
     @Inject
     protected UserVmDao _userVmDao;
+    @Inject
+    protected AsyncJobManager _jobMgr;
+    @Inject
+    ClusterManager clusterManager;
 
     private final StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
     protected List<StoragePoolAllocator> _storagePoolAllocators;
@@ -1355,9 +1366,71 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
         return true;
     }
 
+    private void cleanupVolumeDuringAttachFailure(Long volumeId) {
+        VolumeVO volume = _volsDao.findById(volumeId);
+        if (volume == null) {
+            return;
+        }
+
+        if (volume.getState().equals(Volume.State.Creating)) {
+            s_logger.debug("Remove volume: " + volume.getId() + ", as it's leftover from
last mgt server stop");
+            _volsDao.remove(volume.getId());
+        }
+    }
+
+    private void cleanupVolumeDuringMigrationFailure(Long volumeId, Long destPoolId) {
+        StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destPoolId, DataStoreRole.Primary);
+        if (destPool == null) {
+            return;
+        }
+
+        VolumeVO volume = _volsDao.findById(volumeId);
+        if (volume.getState() == Volume.State.Migrating) {
+            VolumeVO duplicateVol = _volsDao.findByPoolIdName(destPoolId, volume.getName());
+            if (duplicateVol != null) {
+                s_logger.debug("Remove volume " + duplicateVol.getId() + " on storage pool
" + destPoolId);
+                _volsDao.remove(duplicateVol.getId());
+            }
+
+            s_logger.debug("change volume state to ready from migrating in case migration
failure for vol: " + volumeId);
+            volume.setState(Volume.State.Ready);
+            _volsDao.update(volumeId, volume);
+        }
+
+    }
+
+    private void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) {
+        _snapshotSrv.cleanupVolumeDuringSnapshotFailure(volumeId, snapshotId);
+        VolumeVO volume = _volsDao.findById(volumeId);
+        if (volume.getState() == Volume.State.Snapshotting) {
+            s_logger.debug("change volume state back to Ready: " + volume.getId());
+            volume.setState(Volume.State.Ready);
+            _volsDao.update(volume.getId(), volume);
+        }
+    }
+
     @Override
-    public boolean start() {
-        return true;
+    public void cleanupStorageJobs() {
+        //clean up failure jobs related to volume
+        List<AsyncJobVO> jobs = _jobMgr.findFailureAsyncJobs(VmWorkAttachVolume.class.getName(),
+                VmWorkMigrateVolume.class.getName(), VmWorkTakeVolumeSnapshot.class.getName());
+
+        for (AsyncJobVO job : jobs) {
+            try {
+                if (job.getCmd().equalsIgnoreCase(VmWorkAttachVolume.class.getName())) {
+                    VmWorkAttachVolume work = VmWorkSerializer.deserialize(VmWorkAttachVolume.class,
job.getCmdInfo());
+                    cleanupVolumeDuringAttachFailure(work.getVolumeId());
+                } else if (job.getCmd().equalsIgnoreCase(VmWorkMigrateVolume.class.getName()))
{
+                    VmWorkMigrateVolume work = VmWorkSerializer.deserialize(VmWorkMigrateVolume.class,
job.getCmdInfo());
+                    cleanupVolumeDuringMigrationFailure(work.getVolumeId(), work.getDestPoolId());
+                } else if (job.getCmd().equalsIgnoreCase(VmWorkTakeVolumeSnapshot.class.getName()))
{
+                    VmWorkTakeVolumeSnapshot work = VmWorkSerializer.deserialize(VmWorkTakeVolumeSnapshot.class,
job.getCmdInfo());
+                    cleanupVolumeDuringSnapshotFailure(work.getVolumeId(), work.getSnapshotId());
+                }
+            } catch (Exception e) {
+                s_logger.debug("clean up job failure, will continue", e);
+            }
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
index da0a5de..343ec2a 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDao.java
@@ -61,6 +61,8 @@ public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.S
 
     List<VolumeVO> findByPoolId(long poolId);
 
+    VolumeVO findByPoolIdName(long poolId, String name);
+
     List<VolumeVO> findByPoolId(long poolId, Volume.Type volumeType);
 
     List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 4ad196c..24de717 100755
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -126,6 +126,14 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
     }
 
     @Override
+    public VolumeVO findByPoolIdName(long poolId, String name) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("name", name);
+        return findOneBy(sc);
+    }
+
+    @Override
     public List<VolumeVO> findByPoolId(long poolId, Volume.Type volumeType) {
         SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
         sc.setParameters("poolId", poolId);
@@ -306,6 +314,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long>
implements Vol
         AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getState(), Op.EQ);
         AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), Op.NEQ);
         AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), Op.EQ);
+        AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), Op.EQ);
         AllFieldsSearch.done();
 
         DetachedAccountIdSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index 259c51e..5a8afc6 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -446,6 +446,28 @@ public class SnapshotServiceImpl implements SnapshotService {
         }
     }
 
+    @Override
+    public void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) {
+        SnapshotVO snaphsot = _snapshotDao.findById(snapshotId);
+
+        if (snaphsot != null) {
+            if (snaphsot.getState() != Snapshot.State.BackedUp) {
+                List<SnapshotDataStoreVO> snapshotDataStoreVOs = _snapshotStoreDao.findBySnapshotId(snapshotId);
+                for (SnapshotDataStoreVO snapshotDataStoreVO : snapshotDataStoreVOs) {
+                    s_logger.debug("Remove snapshot " + snapshotId + ", status " + snapshotDataStoreVO.getState()
+
+                            " on snapshot_store_ref table with id: " + snapshotDataStoreVO.getId());
+
+                    _snapshotStoreDao.remove(snapshotDataStoreVO.getId());
+                }
+
+                s_logger.debug("Remove snapshot " + snapshotId + " status " + snaphsot.getState()
+ " from snapshot table");
+                _snapshotDao.remove(snapshotId);
+            }
+        }
+
+
+    }
+
     // push one individual snapshots currently on cache store to region store if it is not
there already
     private void syncSnapshotToRegionStore(long snapshotId, DataStore store){
         // if snapshot is already on region wide object store, check if it is really downloaded
there (by checking install_path). Sync snapshot to region

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java
----------------------------------------------------------------------
diff --git a/framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java b/framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java
index 5a70ca5..158a6c3 100644
--- a/framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java
+++ b/framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java
@@ -41,12 +41,13 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.framework.config.ConfigDepot;
 import org.apache.cloudstack.framework.config.ConfigKey;
 import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
 import org.apache.cloudstack.utils.identity.ManagementServerNode;
-import org.apache.log4j.Logger;
 
 import com.cloud.cluster.dao.ManagementServerHostDao;
 import com.cloud.cluster.dao.ManagementServerHostPeerDao;
@@ -958,7 +959,6 @@ public class ClusterManagerImpl extends ManagerBase implements ClusterManager,
C
                     mshost.setAlertCount(0);
                     mshost.setState(ManagementServerHost.State.Up);
                     _mshostDao.persist(mshost);
-
                     if (s_logger.isInfoEnabled()) {
                         s_logger.info("New instance of management server msid " + _msId +
", runId " + _runId + " is being started");
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
index fe5c067..bce99d0 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/AsyncJobManager.java
@@ -129,4 +129,6 @@ public interface AsyncJobManager extends Manager {
     String marshallResultObject(Serializable obj);
 
     Object unmarshallResultObject(AsyncJob job);
+
+    List<AsyncJobVO> findFailureAsyncJobs(String... cmds);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDao.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDao.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDao.java
index 169cae9..8778bef 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDao.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDao.java
@@ -41,4 +41,6 @@ public interface AsyncJobDao extends GenericDao<AsyncJobVO, Long>
{
     List<AsyncJobVO> getExpiredCompletedJobs(Date cutTime, int limit);
 
     List<AsyncJobVO> getResetJobs(long msid);
+
+    List<AsyncJobVO> getFailureJobsSinceLastMsStart(long msId, String... cmds);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
index 0d024eb..a050407 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/AsyncJobDaoImpl.java
@@ -44,6 +44,7 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
     private final SearchBuilder<AsyncJobVO> pseudoJobCleanupSearch;
     private final SearchBuilder<AsyncJobVO> expiringUnfinishedAsyncJobSearch;
     private final SearchBuilder<AsyncJobVO> expiringCompletedAsyncJobSearch;
+    private final SearchBuilder<AsyncJobVO> failureMsidAsyncJobSearch;
 
     public AsyncJobDaoImpl() {
         pendingAsyncJobSearch = createSearchBuilder();
@@ -84,6 +85,13 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
         pseudoJobCleanupSearch.and("initMsid", pseudoJobCleanupSearch.entity().getInitMsid(),
Op.EQ);
         pseudoJobCleanupSearch.done();
 
+        failureMsidAsyncJobSearch = createSearchBuilder();
+        failureMsidAsyncJobSearch.and("initMsid", failureMsidAsyncJobSearch.entity().getInitMsid(),
Op.EQ);
+        failureMsidAsyncJobSearch.and("instanceType", failureMsidAsyncJobSearch.entity().getInstanceType(),
SearchCriteria.Op.EQ);
+        failureMsidAsyncJobSearch.and("status", failureMsidAsyncJobSearch.entity().getStatus(),
SearchCriteria.Op.EQ);
+        failureMsidAsyncJobSearch.and("job_cmd", failureMsidAsyncJobSearch.entity().getCmd(),
Op.IN);
+        failureMsidAsyncJobSearch.done();
+
     }
 
     @Override
@@ -206,4 +214,13 @@ public class AsyncJobDaoImpl extends GenericDaoBase<AsyncJobVO, Long>
implements
         return listIncludingRemovedBy(sc, filter);
 
     }
+
+    @Override
+    public List<AsyncJobVO> getFailureJobsSinceLastMsStart(long msId, String... cmds)
{
+        SearchCriteria<AsyncJobVO> sc = failureMsidAsyncJobSearch.create();
+        sc.setParameters("initMsid", msId);
+        sc.setParameters("status", AsyncJobVO.Status.FAILED);
+        sc.setParameters("job_cmd", (Object[])cmds);
+        return listBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
index 3e26fc1..63a5864 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
@@ -1055,4 +1055,9 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
         _messageBus.publish(null, AsyncJob.Topics.JOB_EVENT_PUBLISH, PublishScope.LOCAL,
             new Pair<AsyncJob, String>(job, jobEvent));
     }
+
+    @Override
+    public List<AsyncJobVO> findFailureAsyncJobs(String... cmds) {
+        return _jobDao.getFailureJobsSinceLastMsStart(getMsid(), cmds);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/server/src/com/cloud/storage/VmWorkAttachVolume.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VmWorkAttachVolume.java b/server/src/com/cloud/storage/VmWorkAttachVolume.java
deleted file mode 100644
index 3cdfbb5..0000000
--- a/server/src/com/cloud/storage/VmWorkAttachVolume.java
+++ /dev/null
@@ -1,40 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import com.cloud.vm.VmWork;
-
-public class VmWorkAttachVolume extends VmWork {
-    private static final long serialVersionUID = 553291814854451740L;
-
-    private Long volumeId;
-    private Long deviceId;
-
-    public VmWorkAttachVolume(long userId, long accountId, long vmId, String handlerName,
Long volumeId, Long deviceId) {
-        super(userId, accountId, vmId, handlerName);
-        this.volumeId = volumeId;
-        this.deviceId = deviceId;
-    }
-
-    public Long getVolumeId() {
-        return volumeId;
-    }
-
-    public Long getDeviceId() {
-        return deviceId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/server/src/com/cloud/storage/VmWorkDetachVolume.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VmWorkDetachVolume.java b/server/src/com/cloud/storage/VmWorkDetachVolume.java
deleted file mode 100644
index 18262d2..0000000
--- a/server/src/com/cloud/storage/VmWorkDetachVolume.java
+++ /dev/null
@@ -1,34 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import com.cloud.vm.VmWork;
-
-public class VmWorkDetachVolume extends VmWork {
-    private static final long serialVersionUID = -8722243207385263101L;
-
-    private Long volumeId;
-
-    public VmWorkDetachVolume(long userId, long accountId, long vmId, String handlerName,
Long volumeId) {
-        super(userId, accountId, vmId, handlerName);
-        this.volumeId = volumeId;
-    }
-
-    public Long getVolumeId() {
-        return volumeId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/server/src/com/cloud/storage/VmWorkMigrateVolume.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VmWorkMigrateVolume.java b/server/src/com/cloud/storage/VmWorkMigrateVolume.java
deleted file mode 100644
index c83e02d..0000000
--- a/server/src/com/cloud/storage/VmWorkMigrateVolume.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import com.cloud.vm.VmWork;
-
-public class VmWorkMigrateVolume extends VmWork {
-    private static final long serialVersionUID = -565778516928408602L;
-
-    private long volumeId;
-    private long destPoolId;
-    private boolean liveMigrate;
-
-    public VmWorkMigrateVolume(long userId, long accountId, long vmId, String handlerName,
long volumeId, long destPoolId, boolean liveMigrate) {
-        super(userId, accountId, vmId, handlerName);
-        this.volumeId = volumeId;
-        this.destPoolId = destPoolId;
-        this.liveMigrate = liveMigrate;
-    }
-
-    public long getVolumeId() {
-        return volumeId;
-    }
-
-    public long getDestPoolId() {
-        return destPoolId;
-    }
-
-    public boolean isLiveMigrate() {
-        return liveMigrate;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/server/src/com/cloud/storage/VmWorkResizeVolume.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VmWorkResizeVolume.java b/server/src/com/cloud/storage/VmWorkResizeVolume.java
deleted file mode 100644
index 4047145..0000000
--- a/server/src/com/cloud/storage/VmWorkResizeVolume.java
+++ /dev/null
@@ -1,73 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import com.cloud.vm.VmWork;
-
-public class VmWorkResizeVolume extends VmWork {
-    private static final long serialVersionUID = 6112366316907642498L;
-
-    private long volumeId;
-    private long currentSize;
-    private long newSize;
-    private Long newMinIops;
-    private Long newMaxIops;
-    private Long newServiceOfferingId;
-    private boolean shrinkOk;
-
-    public VmWorkResizeVolume(long userId, long accountId, long vmId, String handlerName,
-            long volumeId, long currentSize, long newSize, Long newMinIops, Long newMaxIops,
Long newServiceOfferingId, boolean shrinkOk) {
-
-        super(userId, accountId, vmId, handlerName);
-
-        this.volumeId = volumeId;
-        this.currentSize = currentSize;
-        this.newSize = newSize;
-        this.newMinIops = newMinIops;
-        this.newMaxIops = newMaxIops;
-        this.newServiceOfferingId = newServiceOfferingId;
-        this.shrinkOk = shrinkOk;
-    }
-
-    public long getVolumeId() {
-        return volumeId;
-    }
-
-    public long getCurrentSize() {
-        return currentSize;
-    }
-
-    public long getNewSize() {
-        return newSize;
-    }
-
-    public Long getNewMinIops() {
-        return newMinIops;
-    }
-
-    public Long getNewMaxIops() {
-        return newMaxIops;
-    }
-
-    public Long getNewServiceOfferingId() {
-        return newServiceOfferingId;
-    }
-
-    public boolean isShrinkOk() {
-        return shrinkOk;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67113ff0/server/src/com/cloud/storage/VmWorkTakeVolumeSnapshot.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VmWorkTakeVolumeSnapshot.java b/server/src/com/cloud/storage/VmWorkTakeVolumeSnapshot.java
deleted file mode 100644
index 8b23808..0000000
--- a/server/src/com/cloud/storage/VmWorkTakeVolumeSnapshot.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage;
-
-import com.cloud.vm.VmWork;
-
-public class VmWorkTakeVolumeSnapshot extends VmWork {
-
-    private static final long serialVersionUID = 341816293003023823L;
-
-    private Long volumeId;
-    private Long policyId;
-    private Long snapshotId;
-    private boolean quiesceVm;
-
-    public VmWorkTakeVolumeSnapshot(long userId, long accountId, long vmId, String handlerName,
-            Long volumeId, Long policyId, Long snapshotId, boolean quiesceVm) {
-        super(userId, accountId, vmId, handlerName);
-        this.volumeId = volumeId;
-        this.policyId = policyId;
-        this.snapshotId = snapshotId;
-        this.quiesceVm = quiesceVm;
-    }
-
-    public Long getVolumeId() {
-        return volumeId;
-    }
-
-    public Long getPolicyId() {
-        return policyId;
-    }
-
-    public Long getSnapshotId() {
-        return snapshotId;
-    }
-
-    public boolean isQuiesceVm() {
-        return quiesceVm;
-    }
-}


Mime
View raw message