Skip to content

Commit

Permalink
core: fail storage domain attach if getImagesList fails
Browse files Browse the repository at this point in the history
If getImagesList fails due to an error we should not continue with
attaching the SD assuming there no disks on the storage as this will
corrupt the OVF stores.

Instead fail the attach operation and have the user retry once the issue
is resolved.

Bug-Url: https://bugzilla.redhat.com/2126602
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz authored and ahadas committed Nov 6, 2022
1 parent 52fff1c commit 6536fa9
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.ovirt.engine.core.common.errors.EngineException;
import org.ovirt.engine.core.common.errors.EngineMessage;
import org.ovirt.engine.core.common.queries.GetUnregisteredDisksQueryParameters;
import org.ovirt.engine.core.common.queries.QueryReturnValue;
import org.ovirt.engine.core.common.queries.QueryType;
import org.ovirt.engine.core.common.utils.Pair;
import org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters;
Expand Down Expand Up @@ -431,16 +432,23 @@ protected List<DiskImage> getAllOVFDisks(Guid storageDomainId, Guid storagePoolI
ovfDisks = new ArrayList<>();

// Get all unregistered disks.
List<DiskImage> disksFromStorage = backend.runInternalQuery(QueryType.GetUnregisteredDisks,
QueryReturnValue queryReturnValue = backend.runInternalQuery(QueryType.GetUnregisteredDisks,
new GetUnregisteredDisksQueryParameters(storageDomainId,
storagePoolId)).getReturnValue();
if (disksFromStorage == null) {
storagePoolId));
StorageDomain sd = storageDomainDao.get(storageDomainId);
if (sd.getStorageDomainType() == StorageDomainType.Data && !queryReturnValue.getSucceeded()) {
log.error("An error occurred while fetching unregistered disks from Storage Domain id '{}'",
storageDomainId);
throw new RuntimeException("Failed to retrieve unregistered disks");
}

List<DiskImage> disksFromStorage = queryReturnValue.getReturnValue();
if (disksFromStorage == null) {
return ovfDisks;
} else {
castDiskImagesToUnregisteredDisks(disksFromStorage, storageDomainId);
}

for (Disk disk : disksFromStorage) {
DiskImage ovfStoreDisk = (DiskImage) disk;
String diskDescription = ovfStoreDisk.getDescription();
Expand Down

0 comments on commit 6536fa9

Please sign in to comment.