Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
String attachedVmName;
Volume.Type volumeType;
String hostGuidInTargetCluster;
Long newIops;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why newIops is added , not newIopsRead/newIopsWrite ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VMware hypervisor does not allow specifying the IOPS for read and write operations. Instead, you can only specify the IOPS for the disk.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @SadiJr
MigrateVolumeCommand is a class in core module. It might be used if there are similar issues with kvm and/or xenserver which support IOPS read/write.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsato03 Do you think that it makes sense to separate it into read and write IOPS? As @weizhouapache said, this is an agnostic command, so it should be treated like that (meaning separate read and write IOPS).


private DataTO srcData;
private DataTO destData;
Expand Down Expand Up @@ -146,6 +147,14 @@

public String getChainInfo() { return chainInfo; }

public void setNewIops(Long newIops) {
this.newIops = newIops;
}

Check warning on line 152 in core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java#L150-L152

Added lines #L150 - L152 were not covered by tests

public Long getNewIops() {
return newIops;
}

Check warning on line 156 in core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/MigrateVolumeCommand.java#L154-L156

Added lines #L154 - L156 were not covered by tests

@Override
public boolean isReconcile() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
private boolean shrinkOk;
private String vmInstance;
private String chainInfo;
private Long newMaxIops;
private Long newMinIops;
Comment on lines +36 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have max and min IOPs here but on the migrate volume command only IOPS?


/* For managed storage */
private boolean managed;
Expand Down Expand Up @@ -70,7 +72,6 @@
public ResizeVolumeCommand(String path, StorageFilerTO pool, Long currentSize, Long newSize, boolean shrinkOk, String vmInstance,
boolean isManaged, String iScsiName) {
this(path, pool, currentSize, newSize, shrinkOk, vmInstance);

this.iScsiName = iScsiName;
this.managed = isManaged;
}
Expand Down Expand Up @@ -120,4 +121,20 @@
public boolean executeInSequence() {
return false;
}

public Long getNewMaxIops() {
return newMaxIops;
}

Check warning on line 127 in core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java#L125-L127

Added lines #L125 - L127 were not covered by tests

public void setNewMaxIops(Long newMaxIops) {
this.newMaxIops = newMaxIops;
}

Check warning on line 131 in core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java#L129-L131

Added lines #L129 - L131 were not covered by tests

public Long getNewMinIops() {
return newMinIops;
}

Check warning on line 135 in core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java#L133-L135

Added lines #L133 - L135 were not covered by tests

public void setNewMinIops(Long newMinIops) {
this.newMinIops = newMinIops;
}

Check warning on line 139 in core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/api/storage/ResizeVolumeCommand.java#L137-L139

Added lines #L137 - L139 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId,

VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, UserVm vm) throws StorageUnavailableException;

Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException;
Volume migrateVolume(Volume volume, StoragePool destPool, DiskOffering newDiskOffering) throws StorageUnavailableException;

Volume liveMigrateVolume(Volume volume, StoragePool destPool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
throw new CloudRuntimeException(String.format("Failed to find a storage pool with enough capacity to move the volume [%s] to.", volumeToString));
}

Volume newVol = migrateVolume(volumeInfo, destPool);
Volume newVol = migrateVolume(volumeInfo, destPool, diskOffering);

Check warning on line 324 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L324

Added line #L324 was not covered by tests
return volFactory.getVolume(newVol.getId());
}

Expand Down Expand Up @@ -1359,13 +1359,14 @@

@Override
@DB
public Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
public Volume migrateVolume(Volume volume, StoragePool destPool, DiskOffering newDiskOffering) throws StorageUnavailableException {

Check warning on line 1362 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L1362

Added line #L1362 was not covered by tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SadiJr Is this new offering updated on the volume record, when the migrate is successful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sureshanaparti, I did not get what you mean by this, we set the payload with this disk offering, for setting the IOPS later.

String volumeToString = getVolumeIdentificationInfos(volume);

VolumeInfo vol = volFactory.getVolume(volume.getId());
if (vol == null){
throw new CloudRuntimeException(String.format("Volume migration failed because volume [%s] is null.", volumeToString));
}
vol.addPayload(newDiskOffering);

Check warning on line 1369 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L1369

Added line #L1369 was not covered by tests
if (destPool == null) {
throw new CloudRuntimeException("Volume migration failed because the destination storage pool is not available.");
}
Expand Down Expand Up @@ -1494,7 +1495,7 @@
}
logger.debug("Offline VM migration was not done up the stack in VirtualMachineManager. Trying to migrate the VM here.");
for (Map.Entry<Volume, StoragePool> entry : volumeStoragePoolMap.entrySet()) {
Volume result = migrateVolume(entry.getKey(), entry.getValue());
Volume result = migrateVolume(entry.getKey(), entry.getValue(), null);

Check warning on line 1498 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L1498

Added line #L1498 was not covered by tests
if (result == null) {
return false;
}
Expand Down Expand Up @@ -1955,7 +1956,7 @@
} else if (task.type == VolumeTaskType.MIGRATE) {
store = (PrimaryDataStore) dataStoreMgr.getDataStore(task.pool.getId(), DataStoreRole.Primary);
updateVolumeSize(store, task.volume);
vol = migrateVolume(task.volume, store);
vol = migrateVolume(task.volume, store, null);

Check warning on line 1959 in engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java

View check run for this annotation

Codecov / codecov/patch

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java#L1959

Added line #L1959 was not covered by tests
} else if (task.type == VolumeTaskType.RECREATE) {
Pair<VolumeVO, DataStore> result = recreateVolume(task.volume, vm, dest);
store = (PrimaryDataStore) dataStoreMgr.getDataStore(result.second().getId(), DataStoreRole.Primary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Snapshot.Type;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StorageManager;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
Expand Down Expand Up @@ -459,6 +460,16 @@
StoragePool srcPool = (StoragePool)dataStoreMgr.getDataStore(srcData.getDataStore().getId(), DataStoreRole.Primary);
StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), volume.getVolumeType(), waitInterval, volume.getChainInfo());

if (volume.getpayload() instanceof DiskOfferingVO) {
DiskOfferingVO offering = (DiskOfferingVO) volume.getpayload();
Long newIops = null;

Check warning on line 466 in engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java#L465-L466

Added lines #L465 - L466 were not covered by tests
if (offering.getIopsReadRate() != null && offering.getIopsWriteRate() != null) {
newIops = offering.getIopsReadRate() + offering.getIopsWriteRate();

Check warning on line 468 in engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L468 was not covered by tests
}
command.setNewIops(newIops);

Check warning on line 470 in engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L470 was not covered by tests
}

if (srcPool.getParent() != 0) {
command.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.UUID;
import java.util.stream.Collectors;

import com.vmware.vim25.StorageIOAllocationInfo;
import com.cloud.agent.api.CleanupVMCommand;
import javax.naming.ConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar;
Expand Down Expand Up @@ -78,6 +79,7 @@
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.logging.log4j.ThreadContext;
import org.apache.commons.lang3.ObjectUtils;
import org.joda.time.Duration;

import com.cloud.agent.IAgentControl;
Expand Down Expand Up @@ -873,6 +875,8 @@
boolean managed = cmd.isManaged();
String poolUUID = cmd.getPoolUuid();
String chainInfo = cmd.getChainInfo();
Long newMinIops = cmd.getNewMinIops();
Long newMaxIops = cmd.getNewMaxIops();

Check warning on line 879 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L878-L879

Added lines #L878 - L879 were not covered by tests
boolean useWorkerVm = false;

VmwareContext context = getServiceContext();
Expand All @@ -887,8 +891,6 @@
oldSize / (float) ResourceType.bytesToMiB, newSize / (float) ResourceType.bytesToMiB, vmName);
logger.error(errorMsg);
throw new Exception(errorMsg);
} else if (newSize == oldSize) {
return new ResizeVolumeAnswer(cmd, true, "success", newSize * ResourceType.bytesToKiB);
}

if (vmName.equalsIgnoreCase("none")) {
Expand Down Expand Up @@ -982,6 +984,8 @@
VirtualDisk disk = getDiskAfterResizeDiskValidations(vmMo, path);
String vmdkAbsFile = VmwareHelper.getAbsoluteVmdkFile(disk);

setDiskIops(disk, newMinIops, newMaxIops);

Check warning on line 987 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L987 was not covered by tests

if (vmdkAbsFile != null && !vmdkAbsFile.isEmpty()) {
vmMo.updateAdapterTypeIfRequired(vmdkAbsFile);
}
Expand Down Expand Up @@ -1033,6 +1037,22 @@
}
}

/**
* Sets the disk IOPS which is the sum of min IOPS and max IOPS; if they are null, the IOPS limit is set to -1 (unlimited).
*/
private void setDiskIops(VirtualDisk disk, Long newMinIops, Long newMaxIops) {
StorageIOAllocationInfo storageIOAllocation = new StorageIOAllocationInfo();
Long iops = -1L;

Check warning on line 1045 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L1043-L1045

Added lines #L1043 - L1045 were not covered by tests

if (ObjectUtils.allNotNull(newMinIops, newMaxIops) && newMinIops > 0 && newMaxIops > 0) {
iops = newMinIops + newMaxIops;

Check warning on line 1048 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1048 was not covered by tests
}

storageIOAllocation.setLimit(iops);

Check warning on line 1051 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1051 was not covered by tests
logger.debug(LogUtils.logGsonWithoutException("Setting [%s] as the IOPS limit of disk [%s].", iops == -1L ? "unlimited" : iops, disk));
disk.setStorageIOAllocation(storageIOAllocation);
}

Check warning on line 1054 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L1053-L1054

Added lines #L1053 - L1054 were not covered by tests

private VirtualDisk getDiskAfterResizeDiskValidations(VirtualMachineMO vmMo, String volumePath) throws Exception {
Pair<VirtualDisk, String> vdisk = vmMo.getDiskDevice(volumePath);
if (vdisk == null) {
Expand Down Expand Up @@ -4425,7 +4445,7 @@
for (String diskPath : disks) {
DatastoreFile file = new DatastoreFile(diskPath);
VirtualMachineMO vmMo = dcMo.findVm(file.getDir());
Pair<VirtualDisk, String> vds = vmMo.getDiskDevice(file.getFileName(), true);
Pair<VirtualDisk, String> vds = vmMo.getDiskDevice(file.getFileName(), true, false);

Check warning on line 4448 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L4448 was not covered by tests
long virtualsize = vds.first().getCapacityInKB() * 1024;
long physicalsize = primaryStorageDatastoreMo.fileDiskSize(file.getPath());
if (statEntry.containsKey(chainInfo)) {
Expand Down Expand Up @@ -5178,6 +5198,8 @@
volumePath = vmMo.getVmdkFileBaseName(disk);
}
}

setDiskIops(cmd, vmMo, volumePath);

Check warning on line 5202 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L5202 was not covered by tests
VirtualMachineDiskInfoBuilder diskInfoBuilder = vmMo.getDiskInfoBuilder();
chainInfo = _gson.toJson(diskInfoBuilder.getDiskInfoByBackingFileBaseName(volumePath, targetDsMo.getName()));
MigrateVolumeAnswer answer = new MigrateVolumeAnswer(cmd, true, null, volumePath);
Expand All @@ -5190,6 +5212,33 @@
}
}

/**
* Sets the disk IOPS limitation, if the {@link MigrateVolumeCommand} did not specify this limitation, then it is set to -1 (unlimited).
*/
private void setDiskIops(MigrateVolumeCommand cmd, VirtualMachineMO vmMo, String volumePath) throws Exception {

Check warning on line 5218 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L5218 was not covered by tests
Comment on lines +5216 to +5218
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that every time the volume is migrated we inform the IOPS limitation?

Long newIops = cmd.getNewIops() == null ? -1L : cmd.getNewIops();
VirtualDisk disk = vmMo.getDiskDevice(volumePath, true, true).first();

Check warning on line 5220 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L5220 was not covered by tests

try {
logger.debug(LogUtils.logGsonWithoutException("Trying to change disk [%s] IOPS to [%s].", disk, newIops));
VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();

Check warning on line 5225 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L5222-L5225

Added lines #L5222 - L5225 were not covered by tests

StorageIOAllocationInfo storageIOAllocation = new StorageIOAllocationInfo();
storageIOAllocation.setLimit(newIops);
disk.setStorageIOAllocation(storageIOAllocation);

Check warning on line 5229 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L5227-L5229

Added lines #L5227 - L5229 were not covered by tests

deviceConfigSpec.setDevice(disk);
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
vmMo.configureVm(vmConfigSpec);
} catch (Exception e) {
String vmwareDocumentation = "https://kb.vmware.com/s/article/68164";
logger.error(LogUtils.logGsonWithoutException("Failed to change disk [%s] IOPS to [%s] due to [%s]. This happens when the disk controller is IDE." +
" Please read this documentation for more information: [%s]. ", disk, newIops, e.getMessage(), vmwareDocumentation), e);
}
}

Check warning on line 5240 in plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java#L5231-L5240

Added lines #L5231 - L5240 were not covered by tests

private Pair<VirtualDisk, String> getVirtualDiskInfo(VirtualMachineMO vmMo, String srcDiskName) throws Exception {
Pair<VirtualDisk, String> deviceInfo = vmMo.getDiskDevice(srcDiskName);
if (deviceInfo == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.inject.Inject;

import com.cloud.agent.api.to.DiskTO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionStrategy;
Expand Down Expand Up @@ -251,6 +252,17 @@
, sourcePool
, targetPool
, hostIdForVmAndHostGuidInTargetCluster.second(), ((VolumeObjectTO) srcData.getTO()).getChainInfo());

VolumeInfo volumeInfo = (VolumeInfo) srcData;

Check warning on line 256 in plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L256 was not covered by tests
if (volumeInfo.getpayload() instanceof DiskOfferingVO) {
DiskOfferingVO offering = (DiskOfferingVO) volumeInfo.getpayload();
Long newIops = null;

Check warning on line 259 in plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java#L258-L259

Added lines #L258 - L259 were not covered by tests
if (offering.getIopsReadRate() != null && offering.getIopsWriteRate() != null) {
newIops = offering.getIopsReadRate() + offering.getIopsWriteRate();

Check warning on line 261 in plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L261 was not covered by tests
}
cmd.setNewIops(newIops);

Check warning on line 263 in plugins/hypervisors/vmware/src/main/java/org/apache/cloudstack/storage/motion/VmwareStorageMotionStrategy.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L263 was not covered by tests
}

if (sourcePool.getParent() != 0) {
cmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@
}
ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(),
resizeParameter.newSize, resizeParameter.shrinkOk, resizeParameter.instanceName, vol.getChainInfo(), vol.getPassphrase(), vol.getEncryptFormat());
resizeCmd.setNewMinIops(resizeParameter.newMinIops);
resizeCmd.setNewMaxIops(resizeParameter.newMaxIops);

Check warning on line 473 in plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java#L472-L473

Added lines #L472 - L473 were not covered by tests
if (pool.getParent() != 0) {
resizeCmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
}
Expand Down
24 changes: 13 additions & 11 deletions server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,8 @@

validateIops(newMinIops, newMaxIops, volume.getPoolType());
} else {
newMinIops = newDiskOffering.getMinIops();
newMaxIops = newDiskOffering.getMaxIops();
newMinIops = newDiskOffering.getMinIops() != null ? newDiskOffering.getMinIops() : newDiskOffering.getIopsReadRate();
newMaxIops = newDiskOffering.getMaxIops() != null ? newDiskOffering.getMaxIops() : newDiskOffering.getIopsWriteRate();
Comment on lines +1256 to +1257
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should extract this to a method and add a javadoc to it explaining why we are doing it like this.

}

// 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)
Expand Down Expand Up @@ -1322,10 +1322,8 @@
volumeMigrateRequired = true;
}

boolean volumeResizeRequired = false;
if (currentSize != newSize || !compareEqualsIncludingNullOrZero(newMaxIops, volume.getMaxIops()) || !compareEqualsIncludingNullOrZero(newMinIops, volume.getMinIops())) {
volumeResizeRequired = true;
}
boolean volumeResizeRequired = currentSize != newSize || !compareEqualsIncludingNullOrZero(newMaxIops, volume.getMaxIops()) || !compareEqualsIncludingNullOrZero(newMinIops, volume.getMinIops())
|| !compareEqualsIncludingNullOrZero(newMaxIops, diskOffering.getIopsWriteRate()) || !compareEqualsIncludingNullOrZero(newMinIops, diskOffering.getIopsReadRate());
Comment on lines +1325 to +1326
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really dislike assuming that newMaxIops has to equal write and newMinIops has to equal read. We should change this logic to avoid future problems, it is very easy for some other dev to mix these in the future.

if (!volumeMigrateRequired && !volumeResizeRequired && newDiskOffering != null) {
_volsDao.updateDiskOffering(volume.getId(), newDiskOffering.getId());
volume = _volsDao.findById(volume.getId());
Expand Down Expand Up @@ -1390,7 +1388,11 @@
} else if (jobResult instanceof Throwable) {
throw new RuntimeException("Unexpected exception", (Throwable) jobResult);
} else if (jobResult instanceof Long) {
return _volsDao.findById((Long) jobResult);
Long volumeId = (Long) jobResult;

Check warning on line 1391 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1391 was not covered by tests
if (newDiskOffering != null) {
_volsDao.updateDiskOffering(volumeId, newDiskOffering.getId());

Check warning on line 1393 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1393 was not covered by tests
}
return _volsDao.findById(volumeId);

Check warning on line 1395 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1395 was not covered by tests
}
}

Expand Down Expand Up @@ -3730,9 +3732,9 @@
Volume newVol = null;
try {
if (liveMigrateVolume) {
newVol = liveMigrateVolume(volume, destPool);
newVol = liveMigrateVolume(volume, destPool, newDiskOffering);

Check warning on line 3735 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L3735 was not covered by tests
} else {
newVol = _volumeMgr.migrateVolume(volume, destPool);
newVol = _volumeMgr.migrateVolume(volume, destPool, newDiskOffering);

Check warning on line 3737 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L3737 was not covered by tests
}
if (newDiskOffering != null) {
_volsDao.updateDiskOffering(newVol.getId(), newDiskOffering.getId());
Expand All @@ -3748,9 +3750,9 @@
}

@DB
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException {
protected Volume liveMigrateVolume(Volume volume, StoragePool destPool, DiskOfferingVO newDiskOffering) throws StorageUnavailableException {

Check warning on line 3753 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L3753 was not covered by tests
VolumeInfo vol = volFactory.getVolume(volume.getId());

vol.addPayload(newDiskOffering);

Check warning on line 3755 in server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L3755 was not covered by tests
DataStore dataStoreTarget = dataStoreMgr.getDataStore(destPool.getId(), DataStoreRole.Primary);
AsyncCallFuture<VolumeApiResult> future = volService.migrateVolume(vol, dataStoreTarget);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@
if (vm.getState().equals(VirtualMachine.State.Running)) {
volume = volumeManager.liveMigrateVolume(volumeVO, storagePool);
} else {
volume = volumeManager.migrateVolume(volumeVO, storagePool);
volume = volumeManager.migrateVolume(volumeVO, storagePool, dOffering);

Check warning on line 1008 in server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java#L1008

Added line #L1008 was not covered by tests
}
if (volume == null) {
String msg = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2785,9 +2785,13 @@
}

// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception {
public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly, boolean ignoreDotOnPath) throws Exception {

Check warning on line 2788 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L2788

Added line #L2788 was not covered by tests
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");

if (ignoreDotOnPath) {
vmdkDatastorePath = vmdkDatastorePath + ".";

Check warning on line 2792 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java#L2792

Added line #L2792 was not covered by tests
}

DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
String srcBaseName = dsSrcFile.getFileBaseName();
String trimmedSrcBaseName = VmwareHelper.trimSnapshotDeltaPostfix(srcBaseName);
Expand Down
Loading