This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new d5f6b7cd1d1 Fix to create instances with smaller templates (< 1 GB) on
PowerFlex/ScaleIO storage (#11211)
d5f6b7cd1d1 is described below
commit d5f6b7cd1d18ad3b6e8057f3f36e95a0a24b7440
Author: Suresh Kumar Anaparti <[email protected]>
AuthorDate: Tue Jul 22 21:36:26 2025 +0530
Fix to create instances with smaller templates (< 1 GB) on
PowerFlex/ScaleIO storage (#11211)
* Fix to create instances with smaller templates (< 1 GB) on
PowerFlex/ScaleIO storage
* code improvements
---
.../datastore/driver/ScaleIOPrimaryDataStoreDriver.java | 16 ++++++++--------
.../driver/ScaleIOPrimaryDataStoreDriverTest.java | 12 ++++++++++++
.../hypervisor/kvm/storage/StorPoolStorageAdaptor.java | 3 +++
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git
a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java
b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java
index 192ae4636e9..3d2ca5b1d09 100644
---
a/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java
+++
b/plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java
@@ -1230,13 +1230,13 @@ public class ScaleIOPrimaryDataStoreDriver implements
PrimaryDataStoreDriver {
}
org.apache.cloudstack.storage.datastore.api.Volume scaleIOVolume =
client.getVolume(scaleIOVolumeId);
- long newSizeInGB = newSizeInBytes / (1024 * 1024 * 1024);
- long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) *
8.0);
+ double newSizeInGB = newSizeInBytes / (1024.0 * 1024 * 1024);
+ long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) *
8.0);
- if (scaleIOVolume.getSizeInKb() == newSizeIn8gbBoundary << 20) {
+ if (scaleIOVolume.getSizeInKb() == newSizeIn8GBBoundary << 20) {
logger.debug("No resize necessary at API");
} else {
- scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int)
newSizeIn8gbBoundary);
+ scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int)
newSizeIn8GBBoundary);
if (scaleIOVolume == null) {
throw new CloudRuntimeException("Failed to resize volume:
" + volumeInfo.getName());
}
@@ -1362,12 +1362,12 @@ public class ScaleIOPrimaryDataStoreDriver implements
PrimaryDataStoreDriver {
@Override
public long getVolumeSizeRequiredOnPool(long volumeSize, Long
templateSize, boolean isEncryptionRequired) {
- long newSizeInGB = volumeSize / (1024 * 1024 * 1024);
+ double newSizeInGB = volumeSize / (1024.0 * 1024 * 1024);
if (templateSize != null && isEncryptionRequired &&
needsExpansionForEncryptionHeader(templateSize, volumeSize)) {
- newSizeInGB = (volumeSize + (1<<30)) / (1024 * 1024 * 1024);
+ newSizeInGB = (volumeSize + (1<<30)) / (1024.0 * 1024 * 1024);
}
- long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) *
8.0);
- return newSizeIn8gbBoundary * (1024 * 1024 * 1024);
+ long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) *
8.0);
+ return newSizeIn8GBBoundary * (1024 * 1024 * 1024);
}
@Override
diff --git
a/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java
b/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java
index 921dd3d4d9f..610b595ee05 100644
---
a/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java
+++
b/plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java
@@ -555,6 +555,18 @@ public class ScaleIOPrimaryDataStoreDriverTest {
@Test
public void testGetVolumeSizeRequiredOnPool() {
+ Assert.assertEquals(8L * (1024 * 1024 * 1024),
+ scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
+ 52428800,
+ null,
+ false));
+
+ Assert.assertEquals(8L * (1024 * 1024 * 1024),
+ scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
+ 52428800,
+ 52428800L,
+ true));
+
Assert.assertEquals(16L * (1024 * 1024 * 1024),
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
10L * (1024 * 1024 * 1024),
diff --git
a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java
b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java
index d68e9cbd110..897b293f30d 100644
---
a/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java
+++
b/plugins/storage/volume/storpool/src/main/java/com/cloud/hypervisor/kvm/storage/StorPoolStorageAdaptor.java
@@ -139,6 +139,9 @@ public class StorPoolStorageAdaptor implements
StorageAdaptor {
}
public static String getVolumeNameFromPath(final String volumeUuid,
boolean tildeNeeded) {
+ if (volumeUuid == null) {
+ return null;
+ }
if (volumeUuid.startsWith("/dev/storpool/")) {
return volumeUuid.split("/")[3];
} else if (volumeUuid.startsWith("/dev/storpool-byid/")) {