Skip to content

Commit 76f52af

Browse files
authored
removed the use of SharedMountPoint storage type for the StorPool plugin (#6552)
Fixes #6455 The default storage adaptor - LibvirtStorageAdaptor - is used by different storage types and doesn't use the annotation @StorageAdaptorInfo. In this case, a storage plugin that wants to adopt one of the predefined storage pool types will override the default behaviour. If fixing the issue in general (for new storage plugins or current ones that want to reuse the existing storage pool types) would affect all volume/snapshot/VM cases. This will lead to the need of extensive testing for each storage plugin for which we don't have the resources to do it. That's why this patch fixes the old behaviour for the SharedMountPoint by adding a new storage pool type for the StorPool plugin.
1 parent 6842583 commit 76f52af

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

api/src/main/java/com/cloud/storage/Storage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ public static enum StoragePoolType {
148148
PowerFlex(true, true), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
149149
ManagedNFS(true, false),
150150
Linstor(true, true),
151-
DatastoreCluster(true, true); // for VMware, to abstract pool of clusters
151+
DatastoreCluster(true, true), // for VMware, to abstract pool of clusters
152+
StorPool(true, true);
152153

153154
private final boolean shared;
154155
private final boolean overprovisioning;

engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41700to41710.java

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,30 @@
1616
// under the License.
1717
package com.cloud.upgrade.dao;
1818

19-
import com.cloud.upgrade.SystemVmTemplateRegistration;
20-
import com.cloud.utils.exception.CloudRuntimeException;
21-
import org.apache.log4j.Logger;
22-
2319
import java.io.InputStream;
2420
import java.sql.Connection;
21+
import java.util.List;
22+
23+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
24+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
25+
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
26+
import org.apache.log4j.Logger;
27+
28+
import com.cloud.storage.Storage.StoragePoolType;
29+
import com.cloud.storage.VolumeVO;
30+
import com.cloud.storage.dao.VolumeDao;
31+
import com.cloud.storage.dao.VolumeDaoImpl;
32+
import com.cloud.upgrade.SystemVmTemplateRegistration;
33+
import com.cloud.utils.exception.CloudRuntimeException;
2534

2635
public class Upgrade41700to41710 implements DbUpgrade, DbUpgradeSystemVmTemplate {
2736

2837
final static Logger LOG = Logger.getLogger(Upgrade41610to41700.class);
2938
private SystemVmTemplateRegistration systemVmTemplateRegistration;
3039

40+
private PrimaryDataStoreDao storageDao;
41+
private VolumeDao volumeDao;
42+
3143
@Override
3244
public String[] getUpgradableVersionRange() {
3345
return new String[] {"4.17.0.0", "4.17.1.0"};
@@ -56,6 +68,7 @@ public InputStream[] getPrepareScripts() {
5668

5769
@Override
5870
public void performDataMigration(Connection conn) {
71+
updateStorPoolStorageType();
5972
}
6073

6174
@Override
@@ -83,4 +96,25 @@ public void updateSystemVmTemplates(Connection conn) {
8396
throw new CloudRuntimeException("Failed to find / register SystemVM template(s)");
8497
}
8598
}
99+
100+
private void updateStorPoolStorageType() {
101+
storageDao = new PrimaryDataStoreDaoImpl();
102+
List<StoragePoolVO> storPoolPools = storageDao.findPoolsByProvider("StorPool");
103+
for (StoragePoolVO storagePoolVO : storPoolPools) {
104+
if (StoragePoolType.SharedMountPoint == storagePoolVO.getPoolType()) {
105+
storagePoolVO.setPoolType(StoragePoolType.StorPool);
106+
storageDao.update(storagePoolVO.getId(), storagePoolVO);
107+
}
108+
updateStorageTypeForStorPoolVolumes(storagePoolVO.getId());
109+
}
110+
}
111+
112+
private void updateStorageTypeForStorPoolVolumes(long storagePoolId) {
113+
volumeDao = new VolumeDaoImpl();
114+
List<VolumeVO> volumes = volumeDao.findByPoolId(storagePoolId, null);
115+
for (VolumeVO volumeVO : volumes) {
116+
volumeVO.setPoolType(StoragePoolType.StorPool);
117+
volumeDao.update(volumeVO.getId(), volumeVO);
118+
}
119+
}
86120
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,7 +2848,8 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
28482848
dataStoreUrl = "nfs://" + psHost + File.separator + psPath;
28492849
physicalDisk = getPhysicalDiskFromNfsStore(dataStoreUrl, data);
28502850
} else if (primaryDataStoreTO.getPoolType().equals(StoragePoolType.SharedMountPoint) ||
2851-
primaryDataStoreTO.getPoolType().equals(StoragePoolType.Filesystem)) {
2851+
primaryDataStoreTO.getPoolType().equals(StoragePoolType.Filesystem) ||
2852+
primaryDataStoreTO.getPoolType().equals(StoragePoolType.StorPool)) {
28522853
physicalDisk = getPhysicalDiskPrimaryStore(primaryDataStoreTO, data);
28532854
}
28542855
}
@@ -2868,7 +2869,8 @@ public int compare(final DiskTO arg0, final DiskTO arg1) {
28682869
&& (pool.getType() == StoragePoolType.NetworkFilesystem
28692870
|| pool.getType() == StoragePoolType.SharedMountPoint
28702871
|| pool.getType() == StoragePoolType.Filesystem
2871-
|| pool.getType() == StoragePoolType.Gluster)) {
2872+
|| pool.getType() == StoragePoolType.Gluster
2873+
|| pool.getType() == StoragePoolType.StorPool)) {
28722874
setBackingFileFormat(physicalDisk.getPath());
28732875
}
28742876

plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.cloud.utils.script.OutputInterpreter;
4040
import com.cloud.utils.script.Script;
4141

42-
@StorageAdaptorInfo(storagePoolType=StoragePoolType.SharedMountPoint)
42+
@StorageAdaptorInfo(storagePoolType=StoragePoolType.StorPool)
4343
public class StorPoolStorageAdaptor implements StorageAdaptor {
4444
public static void SP_LOG(String fmt, Object... args) {
4545
try (PrintWriter spLogFile = new PrintWriter(new BufferedWriter(new FileWriter("/var/log/cloudstack/agent/storpool-agent.log", true)))) {

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ public void createAsync(DataStore dataStore, DataObject data, AsyncCompletionCal
233233

234234
VolumeVO volume = volumeDao.findById(vinfo.getId());
235235
volume.setPoolId(dataStore.getId());
236-
volume.setPoolType(StoragePoolType.SharedMountPoint);
237236
volume.setPath(path);
238237
volumeDao.update(volume.getId(), volume);
239238

@@ -716,7 +715,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
716715
final String name = StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
717716
StorPoolUtil.spLog("StorpoolPrimaryDataStoreDriverImpl.copyAsnc DST tmpSnapName=%s ,srcUUID=%s", name, srcTO.getUuid());
718717

719-
if (checkStoragePool != null && checkStoragePool.getPoolType().equals(StoragePoolType.SharedMountPoint)) {
718+
if (checkStoragePool != null && checkStoragePool.getPoolType().equals(StoragePoolType.StorPool)) {
720719
SpConnectionDesc conn = StorPoolUtil.getSpConnection(dstData.getDataStore().getUuid(), dstData.getDataStore().getId(), storagePoolDetailsDao, primaryStoreDao);
721720
String baseOn = StorPoolStorageAdaptor.getVolumeNameFromPath(srcTO.getPath(), true);
722721
//uuid tag will be the same as srcData.uuid

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/StorPoolPrimaryDataStoreLifeCycle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
164164
parameters.setUuid(conn.getTemplateName() + ";" + UUID.randomUUID().toString());
165165
parameters.setZoneId(zoneId);
166166
parameters.setProviderName(providerName);
167-
parameters.setType(StoragePoolType.SharedMountPoint);
167+
parameters.setType(StoragePoolType.StorPool);
168168
parameters.setHypervisorType(HypervisorType.KVM);
169169
parameters.setManaged(false);
170170
parameters.setHost("n/a");

0 commit comments

Comments
 (0)