From 9a9363e6b5d04b49ae102e3e607cb8c63e8c0e03 Mon Sep 17 00:00:00 2001 From: Rene Peinthor Date: Thu, 12 Oct 2023 11:35:27 +0200 Subject: [PATCH] linstor: Fix template volume missing on copy node 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. --- .../kvm/storage/LinstorStorageAdaptor.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java index 271f961765be..9e91e13c4d53 100644 --- a/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java +++ b/plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java @@ -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) @@ -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."); } @@ -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(); @@ -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());