Skip to content

Commit b695484

Browse files
committed
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
1 parent dda1133 commit b695484

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStoragePoolManager.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
9797
}
9898

9999
public KVMStoragePool getStoragePool(StoragePoolType type, String uuid) {
100+
100101
StorageAdaptor adaptor = getStorageAdaptor(type);
101102
KVMStoragePool pool = null;
102103
try {
@@ -149,12 +150,15 @@ public KVMPhysicalDisk getPhysicalDisk(StoragePoolType type, String poolUuid, St
149150
if (vol != null) {
150151
break;
151152
}
152-
153-
Thread.sleep(10000);
154153
} catch (Exception e) {
155154
s_logger.debug("Failed to find volume:" + volName + " due to" + e.toString() + ", retry:" + cnt);
156155
errMsg = e.toString();
157156
}
157+
158+
try {
159+
Thread.sleep(30000);
160+
} catch (InterruptedException e) {
161+
}
158162
cnt++;
159163
}
160164

plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,15 @@ public StorageVol getVolume(StoragePool pool, String volName) {
101101
try {
102102
vol = pool.storageVolLookupByName(volName);
103103
} catch (LibvirtException e) {
104-
104+
s_logger.debug("Can't find volume: " + e.toString());
105105
}
106106
if (vol == null) {
107-
storagePoolRefresh(pool);
107+
try {
108+
refreshPool(pool);
109+
} catch (LibvirtException e) {
110+
s_logger.debug("failed to refresh pool: " + e.toString());
111+
}
112+
108113
try {
109114
vol = pool.storageVolLookupByName(volName);
110115
} catch (LibvirtException e) {
@@ -119,6 +124,7 @@ public StorageVol createVolume(Connect conn, StoragePool pool, String uuid,
119124
LibvirtStorageVolumeDef volDef = new LibvirtStorageVolumeDef(UUID
120125
.randomUUID().toString(), size, format, null, null);
121126
s_logger.debug(volDef.toString());
127+
122128
return pool.storageVolCreateXML(volDef.toString(), 0);
123129
}
124130

@@ -128,7 +134,7 @@ public void storagePoolRefresh(StoragePool pool) {
128134
refreshPool(pool);
129135
}
130136
} catch (LibvirtException e) {
131-
137+
s_logger.debug("refresh storage pool failed: " + e.toString());
132138
}
133139
}
134140

@@ -438,6 +444,7 @@ public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
438444
}
439445
return disk;
440446
} catch (LibvirtException e) {
447+
s_logger.debug("Failed to get physical disk:", e);
441448
throw new CloudRuntimeException(e.toString());
442449
}
443450

0 commit comments

Comments
 (0)