You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2024/12/07 14:32:40 UTC
(cloudstack) branch fenchCheck created (now 73ad3c73e72)
This is an automated email from the ASF dual-hosted git repository.
dahn pushed a change to branch fenchCheck
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
at 73ad3c73e72 add check befor fencing
This branch includes the following new commits:
new 73ad3c73e72 add check befor fencing
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(cloudstack) 01/01: add check befor fencing
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch fenchCheck
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 73ad3c73e729d4992e55e6e1e5651452eca19766
Author: leo79901 <sz...@163.com>
AuthorDate: Wed Dec 4 21:39:15 2024 +0800
add check befor fencing
Resolve the issur : Should not shutting down a server which is already shut.
Thanks for DaanHoogland which provide code.
---
.../org/apache/cloudstack/kvm/ha/KVMHAProvider.java | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java
index 14922727d34..4804310378a 100644
--- a/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java
+++ b/plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHAProvider.java
@@ -35,6 +35,7 @@ import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement.PowerOperat
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
import org.apache.log4j.Logger;
import org.joda.time.DateTime;
+import com.cloud.host.Status;
import javax.inject.Inject;
import java.security.InvalidParameterException;
@@ -86,17 +87,23 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro
@Override
public boolean fence(Host r) throws HAFenceException {
-
try {
- if (outOfBandManagementService.isOutOfBandManagementEnabled(r)){
- final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
- return resp.getSuccess();
+ // host exists and is managed OOB
+ if (r != null && outOfBandManagementService.isOutOfBandManagementEnabled(r)) {
+ // check host status
+ if (Status.Down.equals(r.getStatus())) {
+ logger.info("Host " + r.getName() + " is already down. Returning success.");
+ return true;
+ } else {
+ final OutOfBandManagementResponse resp = outOfBandManagementService.executePowerOperation(r, PowerOperation.OFF, null);
+ return resp.getSuccess();
+ }
} else {
- LOG.warn("OOBM fence operation failed for this host " + r.getName());
+ logger.warn("OOBM fence operation failed for this host " + r.getName());
return false;
}
} catch (Exception e){
- LOG.warn("OOBM service is not configured or enabled for this host " + r.getName() + " error is " + e.getMessage());
+ logger.warn("OOBM service is not configured or enabled for this host " + r.getName() + " error is " + e.getMessage());
throw new HAFenceException("OBM service is not configured or enabled for this host " + r.getName() , e);
}
}