use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo in project ovirt-engine by oVirt.
the class GetAddedGlusterServersQuery method getAddedGlusterServers.
private Map<String, String> getAddedGlusterServers(List<GlusterServerInfo> glusterServers) {
Map<String, String> serversAndFingerprint = new HashMap<>();
for (GlusterServerInfo server : glusterServers) {
if (server.getStatus() == PeerStatus.CONNECTED && !serverExists(server)) {
String fingerprint = null;
QueryReturnValue returnValue;
if (getParameters().isServerKeyFingerprintRequired()) {
returnValue = runInternalQuery(QueryType.GetServerSSHKeyFingerprint, new ServerParameters(server.getHostnameOrIp()));
if (returnValue != null && returnValue.getSucceeded() && returnValue.getReturnValue() != null) {
fingerprint = returnValue.getReturnValue().toString();
}
}
serversAndFingerprint.put(server.getHostnameOrIp(), fingerprint == null ? "" : fingerprint);
}
}
return serversAndFingerprint;
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo in project ovirt-engine by oVirt.
the class RemoveVdsCommand method glusterHostRemove.
private void glusterHostRemove() {
if (clusterHasMultipleHosts() && !hasVolumeBricksOnServer()) {
try (EngineLock lock = glusterUtil.acquireGlusterLockWait(getClusterId())) {
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.RemoveGlusterServer, new RemoveGlusterServerVDSParameters(upServer.getId(), getVds().getHostName(), getParameters().isForceAction()));
// If the host is already removed Cluster using Gluster CLI then we can setSucceeded to true.
setSucceeded(returnValue.getSucceeded() || EngineError.GlusterHostIsNotPartOfCluster == returnValue.getVdsError().getCode());
if (!getSucceeded()) {
if (returnValue.getVdsError().getCode() == EngineError.GlusterHostRemoveFailedException) {
List<GlusterServerInfo> glusterServers = getGlusterPeers(upServer);
if (glusterServers != null) {
if (!glusterUtil.isHostExists(glusterServers, getVds())) {
setSucceeded(true);
}
}
}
if (!getSucceeded()) {
getReturnValue().getFault().setError(returnValue.getVdsError().getCode());
getReturnValue().getFault().setMessage(returnValue.getVdsError().getMessage());
errorType = AuditLogType.GLUSTER_SERVER_REMOVE_FAILED;
return;
}
}
// if last but one host in cluster, update the last host's known addresses
if (clusterUtils.getServerCount(getClusterId()) == 2) {
removeOtherKnowAddressesForGlusterServer(upServer.getId());
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo in project ovirt-engine by oVirt.
the class InitGlusterCommandHelper method initGlusterPeerProcess.
/**
* This method executes a "gluster peer probe" to add the newly added host to the cluster - this
* is done only if there's another UP server in cluster and the host being added is not already
* part of the UP server's peer list.
* Also, acquiring a wait lock only during a gluster peer process (wait as there's periodic job that also
* acquires lock.
*/
private boolean initGlusterPeerProcess(VDS vds) {
// condition.
try (EngineLock lock = glusterUtil.acquireGlusterLockWait(vds.getClusterId())) {
Map<String, String> customLogValues = new HashMap<>();
List<VDS> vdsList = vdsDao.getAllForClusterWithStatus(vds.getClusterId(), VDSStatus.Up);
// If the cluster already having Gluster servers, get an up server
if (!vdsList.isEmpty()) {
// If new server is not part of the existing gluster peers, add into peer group
Optional<VDS> potentialUpServer = vdsList.stream().filter(existingVds -> !vds.getId().equals(existingVds.getId())).findFirst();
if (potentialUpServer.isPresent()) {
VDS upServer = potentialUpServer.get();
List<GlusterServerInfo> glusterServers = getGlusterPeers(upServer);
customLogValues.put("Server", upServer.getHostName());
if (glusterServers.isEmpty()) {
customLogValues.put("Command", "gluster peer status");
setNonOperational(vds, NonOperationalReason.GLUSTER_COMMAND_FAILED, customLogValues);
return false;
} else if (!glusterUtil.isHostExists(glusterServers, vds)) {
if (!glusterPeerProbe(vds, upServer.getId(), vds.getHostName())) {
customLogValues.put("Command", "gluster peer probe " + vds.getHostName());
setNonOperational(vds, NonOperationalReason.GLUSTER_COMMAND_FAILED, customLogValues);
return false;
}
int retries = 0;
while (retries < getMaxRetriesGlusterProbeStatus()) {
// though gluster peer probe succeeds, it takes some time for the host to be
// listed as a peer. Return success only when the host is acknowledged as peer
// from another upServer.
VDS newUpServer = getNewUpServer(vds, upServer);
if (newUpServer == null) {
// there's no other up server. so there's no issue with peer status results
return true;
}
List<GlusterServerInfo> newGlusterServers = getGlusterPeers(newUpServer);
if (!glusterUtil.isHostExists(newGlusterServers, vds)) {
log.info("Failed to find host '{}' in gluster peer list from '{}' on attempt {}", vds, newUpServer, ++retries);
// if num of attempts done
if (retries == getMaxRetriesGlusterProbeStatus()) {
customLogValues.put("Command", "gluster peer status " + vds.getHostName());
setNonOperational(vds, NonOperationalReason.GLUSTER_COMMAND_FAILED, customLogValues);
return false;
}
try {
// give time for gluster peer probe to propogate to servers.
Thread.sleep(1000);
} catch (Exception e) {
log.error(e.getMessage());
break;
}
} else {
return true;
}
}
}
}
}
return true;
}
}
use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo in project ovirt-engine by oVirt.
the class GlusterSyncJob method syncServers.
private void syncServers(Cluster cluster, List<VDS> existingServers, List<GlusterServerInfo> fetchedServers) {
log.debug("Existing servers list returned '{}' comparing with fetched servers '{}'", existingServers, fetchedServers);
boolean serverRemoved = false;
Network glusterNetwork = findGlusterNetwork(cluster.getId());
for (VDS server : existingServers) {
GlusterServerInfo glusterServer = findGlusterServer(server, fetchedServers);
if (isSyncableStatus(server.getStatus())) {
if (glusterServer == null) {
if (cluster.supportsVirtService()) {
// If the cluster supports virt service as well, we should not be removing any servers from it, even
// if they have been removed from the Gluster cluster using the Gluster cli, as they could
// potentially be
// used for running VMs. Will mark this server status as DISCONNECTED instead
log.debug("As cluster '{}' supports virt service as well, server '{}' detected as removed from glusterfs will not be removed from engine", cluster.getName(), server.getHostName());
setNonOperational(server);
continue;
}
log.info("Server '{}' has been removed directly using the gluster CLI. Removing it from engine as well.", server.getName());
logUtil.logServerMessage(server, AuditLogType.GLUSTER_SERVER_REMOVED_FROM_CLI);
try (EngineLock lock = glusterUtil.acquireGlusterLockWait(server.getId())) {
removeServerFromDb(server);
// if last but one server, reset alternate probed address for last server
checkAndResetKnownAddress(existingServers, server);
// remove the server from resource manager
runVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(server.getId()));
serverRemoved = true;
} catch (Exception e) {
log.error("Error while removing server '{}' from database: {}", server.getName(), e.getMessage());
log.debug("Exception", e);
}
} else if (server.getStatus() == VDSStatus.Up && glusterServer.getStatus() == PeerStatus.DISCONNECTED) {
// check gluster is running, if down then move the host to Non-Operational
VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GlusterServersList, new VdsIdVDSCommandParametersBase(server.getId()));
if (!returnValue.getSucceeded()) {
setNonOperational(server);
}
} else {
// update correct status and check if all interfaces with gluster network have been peer probed.
updateStatusAndpeerProbeOtherIface(glusterNetwork, server, glusterServer);
}
}
}
if (serverRemoved) {
log.info("Servers detached using gluster CLI is removed from engine after inspecting the Gluster servers" + " list returned '{}' - comparing with db servers '{}'", fetchedServers, existingServers);
}
}
Aggregations