cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/2] git commit: updated refs/heads/4.2-forward to a0de0d0
Date Thu, 22 Aug 2013 22:11:06 GMT
Updated Branches:
  refs/heads/4.2-forward 896eaf335 -> a0de0d017


CLOUDSTACK-4456:
CLOUDSTACK-4457:
CLOUDSTACK-4459:
harden kvm getvolume. It's possible that one volume created on other kvm host, won't show
up on another host, try more times to refresh storage pool if volume won't shown up


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

Branch: refs/heads/4.2-forward
Commit: a0de0d0177a9251756d57ebdbea93f51a597ac1f
Parents: d157e29
Author: Edison Su <sudison@gmail.com>
Authored: Thu Aug 22 14:58:54 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Thu Aug 22 15:10:50 2013 -0700

----------------------------------------------------------------------
 .../test/FakeDriverTestConfiguration.java       | 13 +++++
 .../test/resource/fakeDriverTestContext.xml     |  2 +
 .../storage/datastore/PrimaryDataStoreImpl.java |  6 +++
 .../kvm/resource/LibvirtComputingResource.java  | 19 ++++---
 .../kvm/storage/KVMStoragePoolManager.java      | 33 ++++++++++++
 .../kvm/storage/KVMStorageProcessor.java        | 53 ++++++--------------
 6 files changed, 79 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
index b5421b4..3cf0cb6 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/FakeDriverTestConfiguration.java
@@ -18,6 +18,9 @@
  */
 package org.apache.cloudstack.storage.test;
 
+import com.cloud.storage.snapshot.SnapshotScheduler;
+import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
+import com.cloud.user.DomainManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
 import org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl;
@@ -42,4 +45,14 @@ public class FakeDriverTestConfiguration extends ChildTestConfiguration{
         return strategy;
     }
 
+    @Bean
+    public SnapshotScheduler SnapshotScheduler() {
+        return Mockito.mock(SnapshotScheduler.class);
+    }
+
+    @Bean
+    public DomainManager DomainManager() {
+        return Mockito.mock(DomainManager.class);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml b/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
index 98209de..c3c8ef5 100644
--- a/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
+++ b/engine/storage/integration-test/test/resource/fakeDriverTestContext.xml
@@ -85,4 +85,6 @@
     <bean id="ServiceOfferingDetailsDao" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl"
/>
     <bean id='SnapshotManagerImpl' class='com.cloud.storage.snapshot.SnapshotManagerImpl'/>
     <bean id='SnapshotPolicyDao' class='com.cloud.storage.dao.SnapshotPolicyDaoImpl'/>
+    <bean id='SnapshotScheduleDao' class='com.cloud.storage.dao.SnapshotScheduleDaoImpl'
/>
+
 </beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
index e02d9bc..bbccfcd 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/PrimaryDataStoreImpl.java
@@ -266,6 +266,12 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
             }
         } else if (obj.getType() == DataObjectType.SNAPSHOT) {
             return objectInStoreMgr.create(obj, this);
+        } else if (obj.getType() == DataObjectType.VOLUME) {
+            VolumeVO vol = volumeDao.findById(obj.getId());
+            if (vol != null) {
+                vol.setPoolId(this.getId());
+                volumeDao.update(vol.getId(), vol);
+            }
         }
 
         return objectInStoreMgr.get(obj, this);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 8d00cb7..404a6da 100755
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -3644,10 +3644,10 @@ ServerResource {
                 physicalDisk = secondaryStorage.getPhysicalDisk(volName);
             } else if (volume.getType() != Volume.Type.ISO) {
                 PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore();
-                pool = _storagePoolMgr.getStoragePool(
-                        store.getPoolType(),
-                        store.getUuid());
-                physicalDisk = pool.getPhysicalDisk(data.getPath());
+                physicalDisk = _storagePoolMgr.getPhysicalDisk(  store.getPoolType(),
+                        store.getUuid(),
+                        data.getPath());
+                pool = physicalDisk.getPool();
             }
 
             String volPath = null;
@@ -3720,10 +3720,9 @@ ServerResource {
                 if (volume.getType() == Volume.Type.ROOT) {
                     DataTO data = volume.getData();
                     PrimaryDataStoreTO store = (PrimaryDataStoreTO)data.getDataStore();
-                    KVMStoragePool pool = _storagePoolMgr.getStoragePool(
-                            store.getPoolType(),
-                            store.getUuid());
-                    KVMPhysicalDisk physicalDisk = pool.getPhysicalDisk(data.getPath());
+                    KVMPhysicalDisk physicalDisk = _storagePoolMgr.getPhysicalDisk( store.getPoolType(),
+                            store.getUuid(),
+                            data.getPath());
                     FilesystemDef rootFs = new FilesystemDef(physicalDisk.getPath(), "/");
                     vm.getDevices().addDevice(rootFs);
                     break;
@@ -3765,6 +3764,10 @@ ServerResource {
         // need to umount secondary storage
         String path = disk.getDiskPath();
         String poolUuid = null;
+        if (path.endsWith("systemvm.iso")) {
+            //Don't need to clean up system vm iso, as it's stored in local
+            return true;
+        }
         if (path != null) {
             String[] token = path.split("/");
             if (token.length > 3) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
index 40f4b5b..71bbc15 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java
@@ -31,8 +31,11 @@ import com.cloud.hypervisor.kvm.resource.KVMHAMonitor;
 import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.StorageLayer;
 import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.log4j.Logger;
 
 public class KVMStoragePoolManager {
+    private static final Logger s_logger = Logger
+            .getLogger(KVMStoragePoolManager.class);
     private class StoragePoolInformation {
          String name;
          String host;
@@ -133,6 +136,36 @@ public class KVMStoragePoolManager {
         return createStoragePool(uuid, sourceHost, 0, sourcePath, "", protocol, false);
     }
 
+    public KVMPhysicalDisk getPhysicalDisk(StoragePoolType type, String poolUuid, String
volName) {
+        int cnt = 0;
+        int retries = 10;
+        KVMPhysicalDisk vol = null;
+        //harden get volume, try cnt times to get volume, in case volume is created on other
host
+        String errMsg = "";
+        while (cnt < retries) {
+            try {
+                KVMStoragePool pool = getStoragePool(type, poolUuid);
+                vol = pool.getPhysicalDisk(volName);
+                if (vol != null) {
+                    break;
+                }
+
+                Thread.sleep(10000);
+            } catch (Exception e) {
+                s_logger.debug("Failed to find volume:" + volName + " due to" + e.toString()
+ ", retry:" + cnt);
+                errMsg = e.toString();
+            }
+            cnt++;
+        }
+
+        if (vol == null) {
+            throw new CloudRuntimeException(errMsg);
+        } else {
+            return vol;
+        }
+
+    }
+
     public KVMStoragePool createStoragePool( String name, String host, int port,
                                              String path, String userInfo,
                                              StoragePoolType type) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0de0d01/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
index 95a426a..1d6b58f 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java
@@ -289,8 +289,8 @@ public class KVMStorageProcessor implements StorageProcessor {
             if (primaryPool.getType() == StoragePoolType.CLVM) {
                 vol = templateToPrimaryDownload(templatePath, primaryPool);
             } else {
-                BaseVol = primaryPool.getPhysicalDisk(templatePath);
-                vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(),
primaryPool);
+                BaseVol = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(),
templatePath);
+                vol = storagePoolMgr.createDiskFromTemplate(BaseVol, UUID.randomUUID().toString(),
BaseVol.getPool());
             }
             if (vol == null) {
                 return new CopyCmdAnswer(" Can't create storage volume on storage pool");
@@ -386,28 +386,12 @@ public class KVMStorageProcessor implements StorageProcessor {
         String destVolumePath = destData.getPath();
         String secondaryStorageUrl = nfsStore.getUrl();
         KVMStoragePool secondaryStoragePool = null;
-        KVMStoragePool primaryPool = null;
-        try {
-            try {
-                primaryPool = storagePoolMgr.getStoragePool(
-                        primaryStore.getPoolType(),
-                        primaryStore.getUuid());
-            } catch (CloudRuntimeException e) {
-                if (e.getMessage().contains("not found")) {
-                    primaryPool = storagePoolMgr.createStoragePool(primaryStore.getUuid(),
-                            primaryStore.getHost(), primaryStore.getPort(),
-                            primaryStore.getPath(), null,
-                            primaryStore.getPoolType());
-                } else {
-                    return new CopyCmdAnswer(e.getMessage());
-                }
-            }
 
+        try {
             String volumeName = UUID.randomUUID().toString();
 
-
             String destVolumeName = volumeName + ".qcow2";
-            KVMPhysicalDisk volume = primaryPool.getPhysicalDisk(srcVolumePath);
+            KVMPhysicalDisk volume = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
primaryStore.getUuid(), srcVolumePath);
             secondaryStoragePool = storagePoolMgr.getStoragePoolByURI(
                     secondaryStorageUrl);
             secondaryStoragePool.createFolder(destVolumePath);
@@ -450,18 +434,9 @@ public class KVMStorageProcessor implements StorageProcessor {
 
             secondaryStorage = storagePoolMgr.getStoragePoolByURI(nfsImageStore.getUrl());
 
-            try {
-                primary = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
-            } catch (CloudRuntimeException e) {
-                if (e.getMessage().contains("not found")) {
-                    primary = storagePoolMgr.createStoragePool(primaryStore.getUuid(), primaryStore.getHost(),
-                            primaryStore.getPort(), primaryStore.getPath(), null, primaryStore.getPoolType());
-                } else {
-                    return new CopyCmdAnswer(e.getMessage());
-                }
-            }
+            primary = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid());
 
-            KVMPhysicalDisk disk = primary.getPhysicalDisk(volume.getPath());
+            KVMPhysicalDisk disk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
primaryStore.getUuid(), volume.getPath());
             String tmpltPath = secondaryStorage.getLocalPath() + File.separator + templateFolder;
             this.storageLayer.mkdirs(tmpltPath);
             String templateName = UUID.randomUUID().toString();
@@ -651,9 +626,9 @@ public class KVMStorageProcessor implements StorageProcessor {
             snapshotRelPath = destSnapshot.getPath();
 
             snapshotDestPath = ssPmountPath + File.separator + snapshotRelPath;
-            KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
-                    primaryStore.getUuid());
-            KVMPhysicalDisk snapshotDisk = primaryPool.getPhysicalDisk(volumePath);
+            KVMPhysicalDisk snapshotDisk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
+                    primaryStore.getUuid(), volumePath);
+            KVMStoragePool primaryPool = snapshotDisk.getPool();
 
             /**
              * RBD snapshots can't be copied using qemu-img, so we have to use
@@ -788,6 +763,7 @@ public class KVMStorageProcessor implements StorageProcessor {
         }
     }
 
+
     protected synchronized String attachOrDetachISO(Connect conn, String vmName, String isoPath,
boolean isAttach)
             throws LibvirtException, URISyntaxException, InternalErrorException {
         String isoXml = null;
@@ -957,9 +933,8 @@ public class KVMStorageProcessor implements StorageProcessor {
         String vmName = cmd.getVmName();
         try {
             Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
-            KVMStoragePool primary = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
primaryStore.getUuid());
+            KVMPhysicalDisk phyDisk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
primaryStore.getUuid(), vol.getPath());
 
-            KVMPhysicalDisk phyDisk = primary.getPhysicalDisk(vol.getPath());
             attachOrDetachDisk(conn, true, vmName, phyDisk, disk.getDiskSeq().intValue());
 
             return new AttachAnswer(disk);
@@ -980,9 +955,8 @@ public class KVMStorageProcessor implements StorageProcessor {
         String vmName = cmd.getVmName();
         try {
             Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
-            KVMStoragePool primary = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
primaryStore.getUuid());
+            KVMPhysicalDisk phyDisk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
primaryStore.getUuid(), vol.getPath());
 
-            KVMPhysicalDisk phyDisk = primary.getPhysicalDisk(vol.getPath());
             attachOrDetachDisk(conn, false, vmName, phyDisk, disk.getDiskSeq().intValue());
 
             return new DettachAnswer(disk);
@@ -1054,7 +1028,8 @@ public class KVMStorageProcessor implements StorageProcessor {
             KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(),
                     primaryStore.getUuid());
 
-            KVMPhysicalDisk disk = primaryPool.getPhysicalDisk(volume.getPath());
+            KVMPhysicalDisk disk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(),
+                    primaryStore.getUuid(), volume.getPath());
             if (state == DomainInfo.DomainState.VIR_DOMAIN_RUNNING && !primaryPool.isExternalSnapshot())
{
                 String vmUuid = vm.getUUIDString();
                 Object[] args = new Object[] { snapshotName, vmUuid };


Mime
View raw message