GitHub user slavkap added a comment to the discussion: Issue with Fenced

> Sorry , the checking code should be here:
> 
> ```
> public boolean fence(Host r) throws HAFenceException {
>     try {
>         if (outOfBandManagementService.isOutOfBandManagementEnabled(r)) {
>             // check host status
>             if (r.getStatus().equals(Host.Status.DOWN)) {
>                 LOG.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());
>             return false;
>         }
>     } catch (Exception e) {
>         LOG.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);
>     }
> }
> ```

One suggestion here  if you're using a build with this change

```
public boolean fence(Host r) throws HAFenceException {
    try {
        if (outOfBandManagementService.isOutOfBandManagementEnabled(r)) {
            // check host status
            if (r != null && Host.Status.DOWN.equals(r.getStatus())) {
                LOG.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());
            return false;
        }
    } catch (Exception e) {
        LOG.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);
    }
}
```

GitHub link: 
https://github.com/apache/cloudstack/discussions/10026#discussioncomment-11458906

----
This is an automatically sent email for users@cloudstack.apache.org.
To unsubscribe, please send an email to: users-unsubscr...@cloudstack.apache.org

Reply via email to