Skip to content

Commit 506a462

Browse files
sureshanapartidhslove
authored andcommitted
Storage pool monitor disconnect improvements (apache#12398)
1 parent fa14921 commit 506a462

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

server/src/main/java/com/cloud/storage/listener/StoragePoolMonitor.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.cloud.storage.StorageManager;
2828
import com.cloud.storage.dao.StoragePoolHostDao;
2929
import com.cloud.utils.exception.CloudRuntimeException;
30+
import com.cloud.utils.Profiler;
3031
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
3132
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
3233
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
@@ -200,51 +201,66 @@ public void processConnect(Host host, StartupCommand cmd, boolean forRebalance)
200201
}
201202

202203
@Override
203-
public synchronized boolean processDisconnect(long agentId, Status state) {
204+
public boolean processDisconnect(long agentId, Status state) {
204205
return processDisconnect(agentId, null, null, state);
205206
}
206207

207208
@Override
208-
public synchronized boolean processDisconnect(long agentId, String uuid, String name, Status state) {
209+
public boolean processDisconnect(long agentId, String uuid, String name, Status state) {
210+
logger.debug("Starting disconnect for Agent [id: {}, uuid: {}, name: {}]", agentId, uuid, name);
209211
Host host = _storageManager.getHost(agentId);
210212
if (host == null) {
211213
logger.warn("Agent [id: {}, uuid: {}, name: {}] not found, not disconnecting pools", agentId, uuid, name);
212214
return false;
213215
}
214216

215217
if (host.getType() != Host.Type.Routing) {
218+
logger.debug("Host [id: {}, uuid: {}, name: {}] is not of type {}, skip", agentId, uuid, name, Host.Type.Routing);
216219
return false;
217220
}
218221

222+
logger.debug("Looking for connected Storage Pools for Host [id: {}, uuid: {}, name: {}]", agentId, uuid, name);
219223
List<StoragePoolHostVO> storagePoolHosts = _storageManager.findStoragePoolsConnectedToHost(host.getId());
220224
if (storagePoolHosts == null) {
221-
if (logger.isTraceEnabled()) {
222-
logger.trace("No pools to disconnect for host: {}", host);
223-
}
225+
logger.debug("No pools to disconnect for host: {}", host);
224226
return true;
225227
}
226228

229+
logger.debug("Found {} pools to disconnect for host: {}", storagePoolHosts.size(), host);
227230
boolean disconnectResult = true;
228-
for (StoragePoolHostVO storagePoolHost : storagePoolHosts) {
231+
int storagePoolHostsSize = storagePoolHosts.size();
232+
for (int i = 0; i < storagePoolHostsSize; i++) {
233+
StoragePoolHostVO storagePoolHost = storagePoolHosts.get(i);
234+
logger.debug("Processing disconnect from Storage Pool {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host);
229235
StoragePoolVO pool = _poolDao.findById(storagePoolHost.getPoolId());
230236
if (pool == null) {
237+
logger.debug("No Storage Pool found with id {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host);
231238
continue;
232239
}
233240

234241
if (!pool.isShared()) {
242+
logger.debug("Storage Pool {} ({}) ({} of {}) is not shared for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host);
235243
continue;
236244
}
237245

238246
// Handle only PowerFlex pool for now, not to impact other pools behavior
239247
if (pool.getPoolType() != StoragePoolType.PowerFlex) {
248+
logger.debug("Storage Pool {} ({}) ({} of {}) is not of type {} for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, pool.getPoolType(), host);
240249
continue;
241250
}
242251

252+
logger.debug("Sending disconnect to Storage Pool {} ({}) ({} of {}) for host: {}", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host);
253+
Profiler disconnectProfiler = new Profiler();
243254
try {
255+
disconnectProfiler.start();
244256
_storageManager.disconnectHostFromSharedPool(host, pool);
245257
} catch (Exception e) {
246258
logger.error("Unable to disconnect host {} from storage pool {} due to {}", host, pool, e.toString());
247259
disconnectResult = false;
260+
} finally {
261+
disconnectProfiler.stop();
262+
long disconnectDuration = disconnectProfiler.getDurationInMillis() / 1000;
263+
logger.debug("Finished disconnect with result {} from Storage Pool {} ({}) ({} of {}) for host: {}, duration: {} secs", disconnectResult, pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host, disconnectDuration);
248264
}
249265
}
250266

0 commit comments

Comments
 (0)