Skip to content

Commit 847e1e4

Browse files
author
Anthony Xu
committed
when system VM ping times out, stop system VM
1 parent 783ed9b commit 847e1e4

5 files changed

Lines changed: 22 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ protected boolean handleDisconnectWithoutInvestigation(AgentAttache attache, Sta
775775
}
776776

777777
if (s_logger.isDebugEnabled()) {
778-
s_logger.debug("The next status of agent " + hostId + "is " + nextStatus + ", current status is " + currentStatus);
778+
s_logger.debug("The next status of agent " + hostId + " is " + nextStatus + ", current status is " + currentStatus);
779779
}
780780
}
781781
}
@@ -1513,7 +1513,7 @@ protected void runInContext() {
15131513
|| host.getType() == Host.Type.SecondaryStorageCmdExecutor)) {
15141514

15151515
s_logger.warn("Disconnect agent for CPVM/SSVM due to physical connection close. host: " + host.getId());
1516-
disconnectWithoutInvestigation(agentId, Event.ShutdownRequested);
1516+
disconnectWithoutInvestigation(agentId, Event.PingTimeout);
15171517
} else {
15181518
status_logger.debug("Ping timeout for host " + agentId + ", do invstigation");
15191519
disconnectWithInvestigation(agentId, Event.PingTimeout);

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ public void onAgentDisconnect(long agentId, com.cloud.host.Status state) {
324324
final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
325325
if (proxy != null) {
326326

327+
stopProxy(proxyVmId);
327328
// Disable this feature for now, as it conflicts
328329
// with
329330
// the case of allowing user to reboot console proxy

server/src/com/cloud/storage/secondary/SecondaryStorageListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance)
8888

8989
@Override
9090
public boolean processDisconnect(long agentId, Status state) {
91+
_ssVmMgr.onAgentDisconnect(agentId, state);
9192
return true;
9293
}
9394

server/src/com/cloud/storage/secondary/SecondaryStorageVmManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.agent.api.Command;
2222
import com.cloud.agent.api.StartupCommand;
2323
import com.cloud.host.HostVO;
24+
import com.cloud.host.Status;
2425
import com.cloud.utils.Pair;
2526
import com.cloud.utils.component.Manager;
2627
import com.cloud.vm.SecondaryStorageVmVO;
@@ -45,6 +46,8 @@ public interface SecondaryStorageVmManager extends Manager {
4546

4647
public void onAgentConnect(Long dcId, StartupCommand cmd);
4748

49+
public void onAgentDisconnect(long agentId, Status state);
50+
4851
public boolean generateFirewallConfiguration(Long agentId);
4952

5053
public boolean generateVMSetupCommand(Long hostId);

services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
import com.cloud.host.Host;
7979
import com.cloud.host.HostVO;
8080
import com.cloud.host.Status;
81+
import com.cloud.host.Host.Type;
8182
import com.cloud.host.dao.HostDao;
8283
import com.cloud.hypervisor.Hypervisor.HypervisorType;
8384
import com.cloud.info.RunningHostCountInfo;
@@ -998,6 +999,20 @@ public boolean destroySecStorageVm(long vmId) {
998999
public void onAgentConnect(Long dcId, StartupCommand cmd) {
9991000
}
10001001

1002+
@Override
1003+
public void onAgentDisconnect(long agentId, Status state) {
1004+
HostVO host = _hostDao.findById(agentId);
1005+
if (host == null || !Type.SecondaryStorageVM.equals(host.getType())) {
1006+
return;
1007+
}
1008+
if (state == Status.Alert || state == Status.Disconnected) {
1009+
SecondaryStorageVmVO ssvm = getSSVMfromHost(host);
1010+
if ( ssvm != null ) {
1011+
stopSecStorageVm(ssvm.getId());
1012+
}
1013+
}
1014+
}
1015+
10011016
private String getAllocLockName() {
10021017
// to improve security, it may be better to return a unique mashed
10031018
// name(for example MD5 hashed)

0 commit comments

Comments
 (0)