Skip to content

Commit

Permalink
linstor: Fix template volume missing on copy node
Browse files Browse the repository at this point in the history
A TODO was overseen and never implemented,
which could trigger the following bug:

If Linstor didn't create a resource (diskless or diskfull) on
the cloudstack choosen node, it would not be able to copy the
template data there, it even seems no error was
triggered and the new template file silently just became
empty/corrupt.
  • Loading branch information
rp- committed Oct 12, 2023
1 parent 3e7f21a commit 9a9363e
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ public boolean deleteStoragePool(KVMStoragePool pool) {
return deleteStoragePool(pool.getUuid());
}

/**
* createPhysicalDisk will check if the resource wasn't yet created and do so, also it will make sure
* it is accessible from this node (MakeAvailable).
*/
@Override
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, QemuImg.PhysicalDiskFormat format,
Storage.ProvisioningType provisioningType, long size, byte[] passphrase)
Expand All @@ -214,7 +218,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
rgSpawn.setResourceDefinitionName(rscName);
rgSpawn.addVolumeSizesItem(size / 1024); // linstor uses KiB

s_logger.debug("Linstor: Spawn resource " + rscName);
s_logger.info("Linstor: Spawn resource " + rscName);
ApiCallRcList answers = api.resourceGroupSpawn(lpool.getResourceGroup(), rgSpawn);
handleLinstorApiAnswers(answers, "Linstor: Unable to spawn resource.");
}
Expand All @@ -228,7 +232,11 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
null,
null);

// TODO make available on node
ResourceMakeAvailable rma = new ResourceMakeAvailable();
rma.diskful(true);
ApiCallRcList answers = api.resourceMakeAvailableOnNode(rscName, localNodeName, rma);
handleLinstorApiAnswers(answers,
String.format("Linstor: Unable to make resource %s available on node: %s", rscName, localNodeName));

if (!resources.isEmpty() && !resources.get(0).getVolumes().isEmpty()) {
final String devPath = resources.get(0).getVolumes().get(0).getDevicePath();
Expand Down Expand Up @@ -418,7 +426,7 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
final QemuImgFile srcFile = new QemuImgFile(sourcePath, sourceFormat);

final KVMPhysicalDisk dstDisk = destPools.createPhysicalDisk(
name, QemuImg.PhysicalDiskFormat.RAW, Storage.ProvisioningType.FAT, disk.getVirtualSize(), null);
name, QemuImg.PhysicalDiskFormat.RAW, provisioningType, disk.getVirtualSize(), null);

final QemuImgFile destFile = new QemuImgFile(dstDisk.getPath());
destFile.setFormat(dstDisk.getFormat());
Expand Down

0 comments on commit 9a9363e

Please sign in to comment.