Skip to content

Commit 4262c02

Browse files
KVM HA: Fix CheckOnHostAnswer success flag when there is no heartbeat (#13373)
1 parent 9e8855a commit 4262c02

5 files changed

Lines changed: 8 additions & 4 deletions

File tree

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtCheckOnHostCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public Answer execute(final CheckOnHostCommand command, final LibvirtComputingRe
5555
if (hasHeartBeat) {
5656
return new CheckOnHostAnswer(command, true, "Heart is beating");
5757
} else {
58-
return new CheckOnHostAnswer(command, "Heart is not beating");
58+
return new CheckOnHostAnswer(command, false, "Heart is not beating");
5959
}
6060
} catch (final InterruptedException e) {
6161
return new CheckOnHostAnswer(command, "CheckOnHostCommand: can't get status of host: InterruptedException");

plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHostActivityChecker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public Status getHostAgentStatus(Host host) {
109109
}
110110

111111
Status hostStatusFromNeighbour = checkHostStatusWithNeighbourHosts(host);
112+
logger.debug("{} status reported from itself: {} and neighbor: {}", host.toString(), hostStatusFromItself, hostStatusFromNeighbour);
112113
Status hostStatus = hostStatusFromItself;
113114
if (hostStatusFromNeighbour == Status.Up && (hostStatusFromItself == Status.Disconnected || hostStatusFromItself == Status.Down)) {
114115
hostStatus = Status.Disconnected;

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import javax.xml.xpath.XPathExpressionException;
6262
import javax.xml.xpath.XPathFactory;
6363

64+
import com.cloud.agent.api.CheckOnHostAnswer;
6465
import com.google.gson.JsonObject;
6566
import com.google.gson.JsonParser;
6667

@@ -3130,7 +3131,9 @@ public void testCheckOnHostCommand() {
31303131
assertNotNull(wrapper);
31313132

31323133
final Answer answer = wrapper.execute(command, libvirtComputingResourceMock);
3133-
assertFalse(answer.getResult());
3134+
assertTrue(answer.getResult());
3135+
assertTrue(answer instanceof CheckOnHostAnswer);
3136+
assertFalse(((CheckOnHostAnswer)answer).isAlive());
31343137

31353138
verify(libvirtComputingResourceMock, times(1)).getMonitor();
31363139
}

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5807,7 +5807,7 @@ protected Answer execute(PingTestCommand cmd) {
58075807
}
58085808

58095809
protected Answer execute(CheckOnHostCommand cmd) {
5810-
return new CheckOnHostAnswer(cmd, null, "Not Implmeneted");
5810+
return new CheckOnHostAnswer(cmd, null, "Not Implemented");
58115811
}
58125812

58135813
protected Answer execute(ModifySshKeysCommand cmd) {

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixCheckOnHostCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public final class CitrixCheckOnHostCommandWrapper extends CommandWrapper<CheckO
3131

3232
@Override
3333
public Answer execute(final CheckOnHostCommand command, final CitrixResourceBase citrixResourceBase) {
34-
return new CheckOnHostAnswer(command, "Not Implmeneted");
34+
return new CheckOnHostAnswer(command, "Not Implemented");
3535
}
3636
}

0 commit comments

Comments
 (0)