Skip to content

Commit 6ceac85

Browse files
Fix to create instances with smaller templates (< 1 GB) on PowerFlex/ScaleIO storage
1 parent 9688cbb commit 6ceac85

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

plugins/storage/volume/scaleio/src/main/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,9 +1362,9 @@ public void resize(DataObject dataObject, AsyncCompletionCallback<CreateCmdResul
13621362

13631363
@Override
13641364
public long getVolumeSizeRequiredOnPool(long volumeSize, Long templateSize, boolean isEncryptionRequired) {
1365-
long newSizeInGB = volumeSize / (1024 * 1024 * 1024);
1365+
double newSizeInGB = volumeSize / (1024.0 * 1024 * 1024);
13661366
if (templateSize != null && isEncryptionRequired && needsExpansionForEncryptionHeader(templateSize, volumeSize)) {
1367-
newSizeInGB = (volumeSize + (1<<30)) / (1024 * 1024 * 1024);
1367+
newSizeInGB = (volumeSize + (1<<30)) / (1024.0 * 1024 * 1024);
13681368
}
13691369
long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
13701370
return newSizeIn8gbBoundary * (1024 * 1024 * 1024);

plugins/storage/volume/scaleio/src/test/java/org/apache/cloudstack/storage/datastore/driver/ScaleIOPrimaryDataStoreDriverTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@ public void testCopyOfflineVolumeFailureWhenNoEndpointFound() {
555555

556556
@Test
557557
public void testGetVolumeSizeRequiredOnPool() {
558+
Assert.assertEquals(8L * (1024 * 1024 * 1024),
559+
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
560+
52428800,
561+
null,
562+
false));
563+
564+
Assert.assertEquals(8L * (1024 * 1024 * 1024),
565+
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
566+
52428800,
567+
52428800L,
568+
true));
569+
558570
Assert.assertEquals(16L * (1024 * 1024 * 1024),
559571
scaleIOPrimaryDataStoreDriver.getVolumeSizeRequiredOnPool(
560572
10L * (1024 * 1024 * 1024),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ private static boolean waitForDeviceSymlink(String devPath) {
139139
}
140140

141141
public static String getVolumeNameFromPath(final String volumeUuid, boolean tildeNeeded) {
142+
if (volumeUuid == null) {
143+
return null;
144+
}
142145
if (volumeUuid.startsWith("/dev/storpool/")) {
143146
return volumeUuid.split("/")[3];
144147
} else if (volumeUuid.startsWith("/dev/storpool-byid/")) {

0 commit comments

Comments
 (0)