Skip to content

Commit 8db7cab

Browse files
Storage pool monitor disconnect improvements (#12398)
1 parent 496bc03 commit 8db7cab

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import javax.inject.Inject;
2222

2323
import com.cloud.storage.StorageManager;
24+
import com.cloud.utils.Profiler;
2425
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
2526
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
2627
import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
@@ -144,51 +145,66 @@ public void processConnect(Host host, StartupCommand cmd, boolean forRebalance)
144145
}
145146

146147
@Override
147-
public synchronized boolean processDisconnect(long agentId, Status state) {
148+
public boolean processDisconnect(long agentId, Status state) {
148149
return processDisconnect(agentId, null, null, state);
149150
}
150151

151152
@Override
152-
public synchronized boolean processDisconnect(long agentId, String uuid, String name, Status state) {
153+
public boolean processDisconnect(long agentId, String uuid, String name, Status state) {
154+
logger.debug("Starting disconnect for Agent [id: {}, uuid: {}, name: {}]", agentId, uuid, name);
153155
Host host = _storageManager.getHost(agentId);
154156
if (host == null) {
155157
logger.warn("Agent [id: {}, uuid: {}, name: {}] not found, not disconnecting pools", agentId, uuid, name);
156158
return false;
157159
}
158160

159161
if (host.getType() != Host.Type.Routing) {
162+
logger.debug("Host [id: {}, uuid: {}, name: {}] is not of type {}, skip", agentId, uuid, name, Host.Type.Routing);
160163
return false;
161164
}
162165

166+
logger.debug("Looking for connected Storage Pools for Host [id: {}, uuid: {}, name: {}]", agentId, uuid, name);
163167
List<StoragePoolHostVO> storagePoolHosts = _storageManager.findStoragePoolsConnectedToHost(host.getId());
164168
if (storagePoolHosts == null) {
165-
if (logger.isTraceEnabled()) {
166-
logger.trace("No pools to disconnect for host: {}", host);
167-
}
169+
logger.debug("No pools to disconnect for host: {}", host);
168170
return true;
169171
}
170172

173+
logger.debug("Found {} pools to disconnect for host: {}", storagePoolHosts.size(), host);
171174
boolean disconnectResult = true;
172-
for (StoragePoolHostVO storagePoolHost : storagePoolHosts) {
175+
int storagePoolHostsSize = storagePoolHosts.size();
176+
for (int i = 0; i < storagePoolHostsSize; i++) {
177+
StoragePoolHostVO storagePoolHost = storagePoolHosts.get(i);
178+
logger.debug("Processing disconnect from Storage Pool {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host);
173179
StoragePoolVO pool = _poolDao.findById(storagePoolHost.getPoolId());
174180
if (pool == null) {
181+
logger.debug("No Storage Pool found with id {} ({} of {}) for host: {}", storagePoolHost.getPoolId(), i, storagePoolHostsSize, host);
175182
continue;
176183
}
177184

178185
if (!pool.isShared()) {
186+
logger.debug("Storage Pool {} ({}) ({} of {}) is not shared for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host);
179187
continue;
180188
}
181189

182190
// Handle only PowerFlex pool for now, not to impact other pools behavior
183191
if (pool.getPoolType() != StoragePoolType.PowerFlex) {
192+
logger.debug("Storage Pool {} ({}) ({} of {}) is not of type {} for host: {}, ignore disconnect", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, pool.getPoolType(), host);
184193
continue;
185194
}
186195

196+
logger.debug("Sending disconnect to Storage Pool {} ({}) ({} of {}) for host: {}", pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host);
197+
Profiler disconnectProfiler = new Profiler();
187198
try {
199+
disconnectProfiler.start();
188200
_storageManager.disconnectHostFromSharedPool(host, pool);
189201
} catch (Exception e) {
190202
logger.error("Unable to disconnect host {} from storage pool {} due to {}", host, pool, e.toString());
191203
disconnectResult = false;
204+
} finally {
205+
disconnectProfiler.stop();
206+
long disconnectDuration = disconnectProfiler.getDurationInMillis() / 1000;
207+
logger.debug("Finished disconnect with result {} from Storage Pool {} ({}) ({} of {}) for host: {}, duration: {} secs", disconnectResult, pool.getName(), pool.getUuid(), i, storagePoolHostsSize, host, disconnectDuration);
192208
}
193209
}
194210

0 commit comments

Comments
 (0)