Skip to content

Commit 97d42e9

Browse files
authored
Fix: allow executing CopyCommand operations in parallel when it is set (#5960)
* Invoke the hypervisor guru instead of the guru cycle * Refactor * Remove unused import * Refactor error
1 parent fe03e30 commit 97d42e9

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

engine/components-api/src/main/java/com/cloud/hypervisor/HypervisorGuruManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ public interface HypervisorGuruManager extends Manager {
2424
HypervisorGuru getGuru(HypervisorType hypervisorType);
2525

2626
long getGuruProcessedCommandTargetHost(long hostId, Command cmd);
27+
28+
long getGuruProcessedCommandTargetHost(long hostId, Command cmd, HypervisorType hypervisorType);
2729
}

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentManagerImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,15 @@ public Answer sendTo(final Long dcId, final HypervisorType type, final Command c
342342
}
343343
Answer answer = null;
344344
try {
345-
346-
final long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(host.getId(), cmd);
345+
final long targetHostId = _hvGuruMgr.getGuruProcessedCommandTargetHost(host.getId(), cmd, host.getHypervisorType());
347346
answer = easySend(targetHostId, cmd);
348347
} catch (final Exception e) {
348+
String errorMsg = String.format("Error sending command %s to host %s, due to %s", cmd.getClass().getName(),
349+
host.getUuid(), e.getLocalizedMessage());
350+
s_logger.error(errorMsg);
351+
if (s_logger.isDebugEnabled()) {
352+
s_logger.debug(errorMsg, e);
353+
}
349354
}
350355
if (answer != null) {
351356
return answer;

server/src/main/java/com/cloud/hypervisor/HypervisorGuruManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ public long getGuruProcessedCommandTargetHost(long hostId, Command cmd) {
8181
return hostId;
8282
}
8383

84+
@Override
85+
public long getGuruProcessedCommandTargetHost(long hostId, Command cmd, HypervisorType hypervisorType) {
86+
HypervisorGuru guru = getGuru(hypervisorType);
87+
Pair<Boolean, Long> result = guru.getCommandHostDelegation(hostId, cmd);
88+
return result.first() ? result.second() : hostId;
89+
}
90+
8491
public List<HypervisorGuru> getHvGuruList() {
8592
return _hvGuruList;
8693
}

0 commit comments

Comments
 (0)