Skip to content

Commit 4a86a0d

Browse files
authored
linstor: Fix template volume missing on copy node (#8082)
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.
1 parent 065abe2 commit 4a86a0d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ public boolean deleteStoragePool(KVMStoragePool pool) {
197197
return deleteStoragePool(pool.getUuid());
198198
}
199199

200+
private void makeResourceAvailable(DevelopersApi api, String rscName, boolean diskfull) throws ApiException
201+
{
202+
ResourceMakeAvailable rma = new ResourceMakeAvailable();
203+
rma.diskful(diskfull);
204+
ApiCallRcList answers = api.resourceMakeAvailableOnNode(rscName, localNodeName, rma);
205+
handleLinstorApiAnswers(answers,
206+
String.format("Linstor: Unable to make resource %s available on node: %s", rscName, localNodeName));
207+
}
208+
209+
/**
210+
* createPhysicalDisk will check if the resource wasn't yet created and do so, also it will make sure
211+
* it is accessible from this node (MakeAvailable).
212+
*/
200213
@Override
201214
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, QemuImg.PhysicalDiskFormat format,
202215
Storage.ProvisioningType provisioningType, long size, byte[] passphrase)
@@ -214,7 +227,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
214227
rgSpawn.setResourceDefinitionName(rscName);
215228
rgSpawn.addVolumeSizesItem(size / 1024); // linstor uses KiB
216229

217-
s_logger.debug("Linstor: Spawn resource " + rscName);
230+
s_logger.info("Linstor: Spawn resource " + rscName);
218231
ApiCallRcList answers = api.resourceGroupSpawn(lpool.getResourceGroup(), rgSpawn);
219232
handleLinstorApiAnswers(answers, "Linstor: Unable to spawn resource.");
220233
}
@@ -228,7 +241,7 @@ public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool, Qemu
228241
null,
229242
null);
230243

231-
// TODO make available on node
244+
makeResourceAvailable(api, rscName, true);
232245

233246
if (!resources.isEmpty() && !resources.get(0).getVolumes().isEmpty()) {
234247
final String devPath = resources.get(0).getVolumes().get(0).getDevicePath();
@@ -418,7 +431,7 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
418431
final QemuImgFile srcFile = new QemuImgFile(sourcePath, sourceFormat);
419432

420433
final KVMPhysicalDisk dstDisk = destPools.createPhysicalDisk(
421-
name, QemuImg.PhysicalDiskFormat.RAW, Storage.ProvisioningType.FAT, disk.getVirtualSize(), null);
434+
name, QemuImg.PhysicalDiskFormat.RAW, provisioningType, disk.getVirtualSize(), null);
422435

423436
final QemuImgFile destFile = new QemuImgFile(dstDisk.getPath());
424437
destFile.setFormat(dstDisk.getFormat());

0 commit comments

Comments
 (0)