Skip to content

Commit a129cd5

Browse files
committed
Address reviews
1 parent 3b42fbf commit a129cd5

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed

core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public class MigrateVolumeCommand extends Command {
3636
String attachedVmName;
3737
Volume.Type volumeType;
3838
String hostGuidInTargetCluster;
39+
<<<<<<< HEAD
40+
=======
41+
Long newMaxIops;
42+
Long newMinIops;
43+
>>>>>>> cb43664102 (Address reviews)
3944

4045
private DataTO srcData;
4146
private DataTO destData;
@@ -146,6 +151,25 @@ public int getWaitInMillSeconds() {
146151

147152
public String getChainInfo() { return chainInfo; }
148153

154+
<<<<<<< HEAD
155+
=======
156+
public Long getNewMinIops() {
157+
return newMinIops;
158+
}
159+
160+
public void setNewMinIops(Long newMinIops) {
161+
this.newMinIops = newMinIops;
162+
}
163+
164+
public Long getNewMaxIops() {
165+
return newMaxIops;
166+
}
167+
168+
public void setNewMaxIops(Long newMaxIops) {
169+
this.newMaxIops = newMaxIops;
170+
}
171+
172+
>>>>>>> cb43664102 (Address reviews)
149173
@Override
150174
public boolean isReconcile() {
151175
return true;

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,10 @@ protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
546546
StoragePool srcPool = (StoragePool)dataStoreMgr.getDataStore(srcData.getDataStore().getId(), DataStoreRole.Primary);
547547
StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
548548
MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), volume.getVolumeType(), waitInterval, volume.getChainInfo());
549+
<<<<<<< HEAD
550+
=======
551+
552+
>>>>>>> cb43664102 (Address reviews)
549553
if (srcPool.getParent() != 0) {
550554
command.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
551555
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,6 +5191,43 @@ private Answer execute(MigrateVolumeCommand cmd) {
51915191
}
51925192
}
51935193

5194+
<<<<<<< HEAD
5195+
=======
5196+
/**
5197+
* Sets the disk IOPS limitation, if the {@link MigrateVolumeCommand} did not specify this limitation, then it is set to -1 (unlimited).
5198+
*/
5199+
private void setDiskIops(MigrateVolumeCommand cmd, VirtualMachineMO vmMo, String volumePath) throws Exception {
5200+
Long newIops = -1L;
5201+
Long newMinIops = cmd.getNewMinIops();
5202+
Long newMaxIops = cmd.getNewMaxIops();
5203+
5204+
if (ObjectUtils.allNotNull(newMinIops, newMaxIops) && newMinIops > 0 && newMaxIops > 0) {
5205+
newIops = newMinIops + newMaxIops;
5206+
}
5207+
5208+
VirtualDisk disk = vmMo.getDiskDevice(volumePath, true, true).first();
5209+
5210+
try {
5211+
logger.debug(LogUtils.logGsonWithoutException("Trying to change disk [%s] IOPS to [%s].", disk, newIops));
5212+
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
5213+
VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
5214+
5215+
StorageIOAllocationInfo storageIOAllocation = new StorageIOAllocationInfo();
5216+
storageIOAllocation.setLimit(newIops);
5217+
disk.setStorageIOAllocation(storageIOAllocation);
5218+
5219+
deviceConfigSpec.setDevice(disk);
5220+
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
5221+
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
5222+
vmMo.configureVm(vmConfigSpec);
5223+
} catch (Exception e) {
5224+
String vmwareDocumentation = "https://kb.vmware.com/s/article/68164";
5225+
logger.error(LogUtils.logGsonWithoutException("Failed to change disk [%s] IOPS to [%s] due to [%s]. This happens when the disk controller is IDE." +
5226+
" Please read this documentation for more information: [%s]. ", disk, newIops, e.getMessage(), vmwareDocumentation), e);
5227+
}
5228+
}
5229+
5230+
>>>>>>> cb43664102 (Address reviews)
51945231
private Pair<VirtualDisk, String> getVirtualDiskInfo(VirtualMachineMO vmMo, String srcDiskName) throws Exception {
51955232
Pair<VirtualDisk, String> deviceInfo = vmMo.getDiskDevice(srcDiskName);
51965233
if (deviceInfo == null) {

plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
3939
import org.apache.cloudstack.storage.to.VolumeObjectTO;
4040
import org.apache.commons.collections.CollectionUtils;
41+
import org.apache.commons.lang3.ObjectUtils;
4142
import org.apache.logging.log4j.Logger;
4243
import org.apache.logging.log4j.LogManager;
4344
import org.springframework.stereotype.Component;
@@ -251,6 +252,28 @@ public void copyAsync(DataObject srcData, DataObject destData, Host destHost, As
251252
, sourcePool
252253
, targetPool
253254
, hostIdForVmAndHostGuidInTargetCluster.second(), ((VolumeObjectTO) srcData.getTO()).getChainInfo());
255+
<<<<<<< HEAD
256+
=======
257+
258+
VolumeInfo volume = (VolumeInfo) srcData;
259+
if (volume.getpayload() instanceof DiskOfferingVO) {
260+
DiskOfferingVO offering = (DiskOfferingVO) volume.getpayload();
261+
262+
Long offeringIopsReadRate = offering.getIopsReadRate();
263+
Long offeringIopsWriteRate = offering.getIopsWriteRate();
264+
265+
Long minIops = null;
266+
Long maxIops = null;
267+
if (ObjectUtils.allNotNull(offeringIopsReadRate, offeringIopsWriteRate)) {
268+
minIops = Math.min(offeringIopsReadRate, offeringIopsWriteRate);
269+
maxIops = Math.max(offeringIopsReadRate, offeringIopsWriteRate);
270+
}
271+
272+
cmd.setNewMinIops(minIops);
273+
cmd.setNewMaxIops(maxIops);
274+
}
275+
276+
>>>>>>> cb43664102 (Address reviews)
254277
if (sourcePool.getParent() != 0) {
255278
cmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
256279
}

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,25 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
12661266

12671267
validateIops(newMinIops, newMaxIops, volume.getPoolType());
12681268
} else {
1269+
<<<<<<< HEAD
12691270
newMinIops = newDiskOffering.getMinIops();
12701271
newMaxIops = newDiskOffering.getMaxIops();
1272+
=======
1273+
if (newDiskOffering.getMinIops() != null) {
1274+
newMinIops = newDiskOffering.getMinIops();
1275+
}
1276+
1277+
if (newDiskOffering.getMaxIops() != null) {
1278+
newMaxIops = newDiskOffering.getMaxIops();
1279+
}
1280+
1281+
Long newDiskOfferingIopsReadRate = newDiskOffering.getIopsReadRate();
1282+
Long newDiskOfferingIopsWriteRate = newDiskOffering.getIopsWriteRate();
1283+
if (ObjectUtils.allNull(newMinIops, newMaxIops) && ObjectUtils.allNotNull(newDiskOfferingIopsReadRate, newDiskOfferingIopsWriteRate)) {
1284+
newMaxIops = Math.max(newDiskOfferingIopsReadRate, newDiskOfferingIopsWriteRate);
1285+
newMinIops = Math.min(newDiskOfferingIopsReadRate, newDiskOfferingIopsWriteRate);
1286+
}
1287+
>>>>>>> cb43664102 (Address reviews)
12711288
}
12721289

12731290
// if the hypervisor snapshot reserve value is null, it must remain null (currently only KVM uses null and null is all KVM uses for a value here)
@@ -1335,10 +1352,14 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
13351352
volumeMigrateRequired = true;
13361353
}
13371354

1355+
<<<<<<< HEAD
13381356
boolean volumeResizeRequired = false;
13391357
if (currentSize != newSize || !compareEqualsIncludingNullOrZero(newMaxIops, volume.getMaxIops()) || !compareEqualsIncludingNullOrZero(newMinIops, volume.getMinIops())) {
13401358
volumeResizeRequired = true;
13411359
}
1360+
=======
1361+
boolean volumeResizeRequired = currentSize != newSize || !compareEqualsIncludingNullOrZero(newMaxIops, volume.getMaxIops()) || !compareEqualsIncludingNullOrZero(newMinIops, volume.getMinIops());
1362+
>>>>>>> cb43664102 (Address reviews)
13421363
if (!volumeMigrateRequired && !volumeResizeRequired && newDiskOffering != null) {
13431364
_volsDao.updateDiskOffering(volume.getId(), newDiskOffering.getId());
13441365
volume = _volsDao.findById(volume.getId());
@@ -1403,7 +1424,18 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
14031424
} else if (jobResult instanceof Throwable) {
14041425
throw new RuntimeException("Unexpected exception", (Throwable) jobResult);
14051426
} else if (jobResult instanceof Long) {
1427+
<<<<<<< HEAD
14061428
return _volsDao.findById((Long) jobResult);
1429+
=======
1430+
Long volumeId = (Long) jobResult;
1431+
if (newDiskOffering != null) {
1432+
_volsDao.updateDiskOffering(volumeId, newDiskOffering.getId());
1433+
}
1434+
volume.setMinIops(newMinIops);
1435+
volume.setMinIops(newMaxIops);
1436+
_volsDao.update(volumeId, volume);
1437+
return _volsDao.findById(volumeId);
1438+
>>>>>>> cb43664102 (Address reviews)
14071439
}
14081440
}
14091441

setup/dev/demo.cfg

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"dbSvr": {
3+
"dbSvr": "192.168.104.160",
4+
"passwd": "password",
5+
"db": "cloud",
6+
"port": 3306,
7+
"user": "cloud"
8+
},
9+
"logger": {
10+
"LogFolderPath": "/tmp/"
11+
},
12+
"mgtSvr": [
13+
{
14+
"mgtSvrIp": "192.168.103.150",
15+
"port": 8096,
16+
"user": "root",
17+
"passwd": "password",
18+
"hypervisor": "kvm"
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)