KVM HA: Fix CheckOnHostAnswer success flag when there is no heartbeat (#13373)

This commit is contained in:
Suresh Kumar Anaparti 2026-07-06 17:26:04 +05:30 committed by GitHub
parent 9e8855a6f5
commit 4262c026d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 4 deletions

View File

@ -55,7 +55,7 @@ public final class LibvirtCheckOnHostCommandWrapper extends CommandWrapper<Check
if (hasHeartBeat) {
return new CheckOnHostAnswer(command, true, "Heart is beating");
} else {
return new CheckOnHostAnswer(command, "Heart is not beating");
return new CheckOnHostAnswer(command, false, "Heart is not beating");
}
} catch (final InterruptedException e) {
return new CheckOnHostAnswer(command, "CheckOnHostCommand: can't get status of host: InterruptedException");

View File

@ -109,6 +109,7 @@ public class KVMHostActivityChecker extends AdapterBase implements ActivityCheck
}
Status hostStatusFromNeighbour = checkHostStatusWithNeighbourHosts(host);
logger.debug("{} status reported from itself: {} and neighbor: {}", host.toString(), hostStatusFromItself, hostStatusFromNeighbour);
Status hostStatus = hostStatusFromItself;
if (hostStatusFromNeighbour == Status.Up && (hostStatusFromItself == Status.Disconnected || hostStatusFromItself == Status.Down)) {
hostStatus = Status.Disconnected;

View File

@ -61,6 +61,7 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import com.cloud.agent.api.CheckOnHostAnswer;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@ -3130,7 +3131,9 @@ public class LibvirtComputingResourceTest {
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, libvirtComputingResourceMock);
assertFalse(answer.getResult());
assertTrue(answer.getResult());
assertTrue(answer instanceof CheckOnHostAnswer);
assertFalse(((CheckOnHostAnswer)answer).isAlive());
verify(libvirtComputingResourceMock, times(1)).getMonitor();
}

View File

@ -5807,7 +5807,7 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
}
protected Answer execute(CheckOnHostCommand cmd) {
return new CheckOnHostAnswer(cmd, null, "Not Implmeneted");
return new CheckOnHostAnswer(cmd, null, "Not Implemented");
}
protected Answer execute(ModifySshKeysCommand cmd) {

View File

@ -31,6 +31,6 @@ public final class CitrixCheckOnHostCommandWrapper extends CommandWrapper<CheckO
@Override
public Answer execute(final CheckOnHostCommand command, final CitrixResourceBase citrixResourceBase) {
return new CheckOnHostAnswer(command, "Not Implmeneted");
return new CheckOnHostAnswer(command, "Not Implemented");
}
}