Skip to content

Commit d5f6b7c

Browse files
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
1 parent 23de6c7 commit d5f6b7c

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,13 +1230,13 @@ private void resizeVolume(VolumeInfo volumeInfo) {
12301230
}
12311231

12321232
org.apache.cloudstack.storage.datastore.api.Volume scaleIOVolume = client.getVolume(scaleIOVolumeId);
1233-
long newSizeInGB = newSizeInBytes / (1024 * 1024 * 1024);
1234-
long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
1233+
double newSizeInGB = newSizeInBytes / (1024.0 * 1024 * 1024);
1234+
long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
12351235

1236-
if (scaleIOVolume.getSizeInKb() == newSizeIn8gbBoundary << 20) {
1236+
if (scaleIOVolume.getSizeInKb() == newSizeIn8GBBoundary << 20) {
12371237
logger.debug("No resize necessary at API");
12381238
} else {
1239-
scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int) newSizeIn8gbBoundary);
1239+
scaleIOVolume = client.resizeVolume(scaleIOVolumeId, (int) newSizeIn8GBBoundary);
12401240
if (scaleIOVolume == null) {
12411241
throw new CloudRuntimeException("Failed to resize volume: " + volumeInfo.getName());
12421242
}
@@ -1362,12 +1362,12 @@ 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
}
1369-
long newSizeIn8gbBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
1370-
return newSizeIn8gbBoundary * (1024 * 1024 * 1024);
1369+
long newSizeIn8GBBoundary = (long) (Math.ceil(newSizeInGB / 8.0) * 8.0);
1370+
return newSizeIn8GBBoundary * (1024 * 1024 * 1024);
13711371
}
13721372

13731373
@Override

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)