CLOUDSTACK-4459:

Libvirt reports:
org.libvirt.LibvirtException: Storage volume not found: no storage vol
with matching name
in some cases, if the volume is created on one kvm host, while accessed
from other host.
It's possible due to concurrent access(read/write) storage.
The current fix is to try serveral times, and wait for 30 seconds for
each retry.
If the issue still there, then need to sync the storage pool access
This commit is contained in:
Edison Su 2013-08-26 18:07:18 -07:00
parent dda1133f12
commit b695484dc7
2 changed files with 16 additions and 5 deletions

View File

@ -97,6 +97,7 @@ public class KVMStoragePoolManager {
}
public KVMStoragePool getStoragePool(StoragePoolType type, String uuid) {
StorageAdaptor adaptor = getStorageAdaptor(type);
KVMStoragePool pool = null;
try {
@ -149,12 +150,15 @@ public class KVMStoragePoolManager {
if (vol != null) {
break;
}
Thread.sleep(10000);
} catch (Exception e) {
s_logger.debug("Failed to find volume:" + volName + " due to" + e.toString() + ", retry:" + cnt);
errMsg = e.toString();
}
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
}
cnt++;
}

View File

@ -101,10 +101,15 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
try {
vol = pool.storageVolLookupByName(volName);
} catch (LibvirtException e) {
s_logger.debug("Can't find volume: " + e.toString());
}
if (vol == null) {
storagePoolRefresh(pool);
try {
refreshPool(pool);
} catch (LibvirtException e) {
s_logger.debug("failed to refresh pool: " + e.toString());
}
try {
vol = pool.storageVolLookupByName(volName);
} catch (LibvirtException e) {
@ -119,6 +124,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID
.randomUUID().toString(), size, format, null, null);
s_logger.debug(volDef.toString());
return pool.storageVolCreateXML(volDef.toString(), 0);
}
@ -128,7 +134,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
refreshPool(pool);
}
} catch (LibvirtException e) {
s_logger.debug("refresh storage pool failed: " + e.toString());
}
}
@ -438,6 +444,7 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
}
return disk;
} catch (LibvirtException e) {
s_logger.debug("Failed to get physical disk:", e);
throw new CloudRuntimeException(e.toString());
}