Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: use manged_path for running VMs with MBS devices #104

Merged
merged 4 commits into from
Jun 2, 2022
Merged
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
@@ -1,6 +1,7 @@
package org.ovirt.engine.core.bll.storage.disk.image;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -329,7 +330,7 @@ private ManagedBlockStorageDisk createManagedBlockDiskFromDiskImage(DiskImage di
managedBlockDisk.setImageId(getParameters().getDestinationImageId());
managedBlockDisk.setDiskAlias(getParameters().getDiskAlias());
managedBlockDisk.setDiskDescription(getParameters().getDescription());
managedBlockDisk.getStorageIds().add(getParameters().getDestDomain());
managedBlockDisk.setStorageIds(Arrays.asList(getParameters().getDestDomain()));

return managedBlockDisk;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private VDSReturnValue detachVolume() {
AttachManagedBlockStorageVolumeVDSCommandParameters params =
Copy link
Member

Choose a reason for hiding this comment

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

This is similar to the previous commit adding sd_id, no?

new AttachManagedBlockStorageVolumeVDSCommandParameters(vds);
params.setVolumeId(getParameters().getDiskId());
params.setStorageDomainId(getParameters().getStorageDomainId());
return runVdsCommand(VDSCommandType.DetachManagedBlockStorageVolume, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ public VDSReturnValue attachManagedBlockStorageDisk(ManagedBlockStorageDisk disk

Copy link
Member

Choose a reason for hiding this comment

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

Change makes sense - but is required only to allow LSM which is not supported yet.
Can we defer this change so we can merge sooner the lightos support?

Until we do this change, all disks will use blank uuid. Adding the sd id is likely
wanted also in 4.5.1, but we can add it after the basics are merged, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

the vdsm PR included these changes so I tested them all together, I can separate it now since it's merged in vdsm

disk.setConnectionInfo(returnValue.getActionReturnValue());
AttachManagedBlockStorageVolumeVDSCommandParameters params =
new AttachManagedBlockStorageVolumeVDSCommandParameters(vds, returnValue.getActionReturnValue());
new AttachManagedBlockStorageVolumeVDSCommandParameters(vds,
returnValue.getActionReturnValue(),
disk.getStorageIds().get(0));
params.setVolumeId(disk.getImageId());
return resourceManager.runVdsCommand(VDSCommandType.AttachManagedBlockStorageVolume, params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class AttachManagedBlockStorageVolumeVDSCommandParameters extends VdsIdAn

private Map<String, Object> connectionInfo;
private Guid volumeId;
private Guid storageDomainId;

public AttachManagedBlockStorageVolumeVDSCommandParameters() {
}
Expand All @@ -18,9 +19,11 @@ public AttachManagedBlockStorageVolumeVDSCommandParameters(VDS vds) {
}

public AttachManagedBlockStorageVolumeVDSCommandParameters(VDS vds,
Map<String, Object> connectionInfo) {
Map<String, Object> connectionInfo,
Guid storageDomainId) {
super(vds);
this.connectionInfo = connectionInfo;
this.storageDomainId = storageDomainId;
}

public AttachManagedBlockStorageVolumeVDSCommandParameters(Map<String, Object> connectionInfo) {
Expand All @@ -42,4 +45,12 @@ public Guid getVolumeId() {
public void setVolumeId(Guid volumeId) {
this.volumeId = volumeId;
}

public Guid getStorageDomainId() {
return storageDomainId;
}

public void setStorageDomainId(Guid storageDomainId) {
this.storageDomainId = storageDomainId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2437,21 +2437,22 @@ private void writeDiskSource(VmDevice device, Disk disk, String dev, DiskVmEleme
case MANAGED_BLOCK_STORAGE:
ManagedBlockStorageDisk managedBlockStorageDisk = (ManagedBlockStorageDisk) disk;
Map<String, String> metadata = new HashMap<>();
String path = (String) managedBlockStorageDisk.getDevice().get(DeviceInfoReturn.PATH);
String path;
if (Version.v4_7.lessOrEquals(vm.getCompatibilityVersion())) {
path = (String) managedBlockStorageDisk.getDevice().get(DeviceInfoReturn.MANAGED_PATH);
} else {
path = (String) managedBlockStorageDisk.getDevice().get(DeviceInfoReturn.PATH);
}
Copy link
Member

Choose a reason for hiding this comment

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

How does this work for running vm when we upgrade the cluster version while the vm is running?

The vm will start using "path". After the upgrade, if we migrate the vm, we will use "managed_path", and the migration will likely fail.

Can we always use "managed_path"?

Copy link
Member Author

Choose a reason for hiding this comment

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

what about older cluster levels, if we do live migration in a 4.6 cluster for example?

Copy link
Member

Choose a reason for hiding this comment

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

Migration to/from 4.6 cluster will not work with managed_path. But since this is tech preview we don't need to care about it.

If we want to avoid this issue we can use managed_path only for lightos, and continue to use path for rbd and mpath. But this means we carry to ways to work with mbs storage, which is bad. I this to break this now and not later.

Copy link
Member

Choose a reason for hiding this comment

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

Now it is clear, we use manage_path for cluster level 4.7, and path for older cluster levels since vdsm in older versions did not support managed_path.


if (managedBlockStorageDisk.getCinderVolumeDriver() == CinderVolumeDriver.RBD) {
// For rbd we need to pass the entire path since we rely on more than a single
// variable e.g: /dev/rbd/<pool-name>/<vol-name>
metadata = Collections.singletonMap("RBD", path);
metadata.put("RBD", path);
Copy link
Member

Choose a reason for hiding this comment

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

So before we started with empty map, and then replaced it with Collections.singletonMap?
Using metadata looks good, but is this change needed to support managed_path or a cleanup that we can do later?

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately it is not a cleanup, singletonMap was incorrect because it's immutable which would prevent setting metadata.put("managed", "true"); later on

} else if (managedBlockStorageDisk.getCinderVolumeDriver() == CinderVolumeDriver.BLOCK) {
Map<String, Object> attachment =
(Map<String, Object>) managedBlockStorageDisk.getDevice().get(DeviceInfoReturn.ATTACHMENT);
metadata = Map.of(
"GUID", (String)attachment.get(DeviceInfoReturn.SCSI_WWN),
"managed", "true"
);
metadata.put("GUID", (String)attachment.get(DeviceInfoReturn.SCSI_WWN));
Copy link
Member

Choose a reason for hiding this comment

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

This is also nicer, but is this require to get this change merged?

}

metadata.put("managed", "true");
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this the only required change?

writer.writeAttributeString("dev", path);
diskMetadata.put(dev, metadata);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2631,21 +2631,23 @@ public StatusOnlyReturn glusterVolumeResetBrickCommitForce(String volumeName,
}

@Override
public DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Map<String, Object> connectionInfo) {
public DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID, Map<String, Object> connectionInfo) {
JsonRpcRequest request =
new RequestBuilder("ManagedVolume.attach_volume")
.withParameter("vol_id", volumeId.toString())
.withParameter("connection_info", connectionInfo)
.withParameter("sd_id", sdUUID.toString())
.build();
Map<String, Object> response = new FutureMap(this.client, request);
return new DeviceInfoReturn(response);
}

@Override
public StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId) {
public StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID) {
JsonRpcRequest request =
new RequestBuilder("ManagedVolume.detach_volume")
.withParameter("vol_id", volumeId.toString())
.withParameter("sd_id", sdUUID.toString())
.build();
Map<String, Object> response = new FutureMap(this.client, request);
return new StatusOnlyReturn(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public AttachManagedBlockStorageVolumeVDSCommand(P parameters) {
@Override
protected void executeVdsBrokerCommand() {
deviceInfoReturn =
getBroker().attachManagedBlockStorageVolume(getParameters().getVolumeId(), getParameters().getConnectionInfo());
getBroker().attachManagedBlockStorageVolume(getParameters().getVolumeId(),
getParameters().getStorageDomainId(),
getParameters().getConnectionInfo());
proceedProxyReturnValue();
setReturnValue(deviceInfoReturn.getDeviceInfo());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public DetachManagedBlockStorageVolumeVDSCommand(P parameters) {

@Override
protected void executeVdsBrokerCommand() {
status = getBroker().detachManagedBlockStorageVolume(getParameters().getVolumeId());
status = getBroker().detachManagedBlockStorageVolume(getParameters().getVolumeId(),
getParameters().getStorageDomainId());
proceedProxyReturnValue();
setReturnValue(status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public class DeviceInfoReturn extends StatusReturn {
public static final String PATH = "path";
public static final String MANAGED_PATH = "managed_path";
public static final String TYPE = "type";
public static final String SCSI_WWN = "scsi_wwn";
public static final String ATTACHMENT = "attachment";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ MeasureReturn measureVolume(String sdUUID,
StatusOnlyReturn glusterVolumeResetBrickCommitForce(String volumeName,
String existingBrickDir);

DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Map<String, Object> connectionInfo);
DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID, Map<String, Object> connectionInfo);

StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId);
StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID);

VDSInfoReturn getLeaseStatus(String leaseUUID, String sdUUID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,11 +1078,11 @@ public StatusOnlyReturn amendVolume(String jobId, Map<String, Object> volInfo, M
}

@Override
public DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Map<String, Object> connectionInfo) {
public DeviceInfoReturn attachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID, Map<String, Object> connectionInfo) {
return null;
}

@Override public StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId) {
@Override public StatusOnlyReturn detachManagedBlockStorageVolume(Guid volumeId, Guid sdUUID) {
return null;
}

Expand Down