Liron Ar has uploaded a new change for review.

Change subject: core: Host shouldn't move to UP if it's already connected to 
other pool
......................................................................

core: Host shouldn't move to UP if it's already connected to other pool

When host fails to connect to the pool, it shouldn't move to UP if it's
already connected to other pool regardless of the master domain status.

Regardless of this change, the error handling in
ConnectStoragePoolVdsCommand should be changed as well as the error
handling in it's callers, this change handles InitVdsOnUp.

Change-Id: Ifd3d8268516b010f7831b59bbc6331cfd70efec1
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1023732
Signed-off-by: Liron Aravot <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java
1 file changed, 16 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/21095/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java
index 947f4a9..7d24601 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java
@@ -34,7 +34,9 @@
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterServer;
 import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
+import org.ovirt.engine.core.common.errors.VDSError;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
+import org.ovirt.engine.core.common.errors.VdcBllErrors;
 import org.ovirt.engine.core.common.eventqueue.Event;
 import org.ovirt.engine.core.common.eventqueue.EventQueue;
 import org.ovirt.engine.core.common.eventqueue.EventResult;
@@ -58,6 +60,7 @@
 import org.ovirt.engine.core.utils.ejb.BeanProxyType;
 import org.ovirt.engine.core.utils.ejb.BeanType;
 import org.ovirt.engine.core.utils.ejb.EjbUtils;
+import org.ovirt.engine.core.vdsbroker.ResourceManager;
 import org.ovirt.engine.core.vdsbroker.attestation.AttestationService;
 import org.ovirt.engine.core.vdsbroker.attestation.AttestationValue;
 import org.ovirt.engine.core.vdsbroker.irsbroker.IrsBrokerCommand;
@@ -214,23 +217,26 @@
     private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, 
final VDS vds) {
         EventResult result = new EventResult(true, EventType.VDSCONNECTTOPOOL);
         StoragePool storagePool = getStoragePoolDAO().get(storagePoolId);
-        StorageDomain masterDomain = 
getStorageDomainDAO().getStorageDomainByTypeAndPool(storagePoolId, 
StorageDomainType.Master);
+        StorageDomain masterDomain =
+                
getStorageDomainDAO().getStorageDomainByTypeAndPool(storagePoolId, 
StorageDomainType.Master);
         boolean masterDomainInactiveOrUnknown = masterDomain.getStatus() == 
StorageDomainStatus.InActive
                 || masterDomain.getStatus() == StorageDomainStatus.Unknown;
-        try {
-            runVdsCommand(VDSCommandType.ConnectStoragePool,
-                    new ConnectStoragePoolVDSCommandParameters(vds.getId(), 
storagePoolId,
-                            vds.getVdsSpmId(), masterDomain.getId(),
-                            storagePool.getmaster_domain_version()));
-        } catch (VdcBLLException e) {
-            if (masterDomainInactiveOrUnknown) {
+
+        VDSReturnValue returnValue = 
ResourceManager.getInstance().runVdsCommand(VDSCommandType.ConnectStoragePool,
+                new ConnectStoragePoolVDSCommandParameters(vds.getId(), 
storagePoolId,
+                        vds.getVdsSpmId(), masterDomain.getId(),
+                        storagePool.getmaster_domain_version()));
+        if (!returnValue.getSucceeded()) {
+            VDSError error = returnValue.getVdsError();
+            if ((error == null || error.getCode() != 
VdcBllErrors.CannotConnectMultiplePools)
+                    && masterDomainInactiveOrUnknown) {
                 log.infoFormat("Could not connect host {0} to pool {1}, as the 
master domain is in inactive/unknown status - not failing the operation",
                         vds.getName(),
                         storagePool
                                 .getName());
             } else {
-                log.errorFormat("Could not connect host {0} to pool {1}", 
vds.getName(), storagePool
-                        .getName());
+                log.errorFormat("Could not connect host {0} to pool {1} with 
the message: {2}", vds.getName(), storagePool
+                        .getName(), error != null ? 
returnValue.getVdsError().getMessage() : "");
                 result.setSuccess(false);
             }
         }


-- 
To view, visit http://gerrit.ovirt.org/21095
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifd3d8268516b010f7831b59bbc6331cfd70efec1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Liron Ar <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to