Maor Lipchuk has uploaded a new change for review.

Change subject: core:Initialize host name for CDA message(BZ846771)
......................................................................

core:Initialize host name for CDA message(BZ846771)

https://bugzilla.redhat.com/show_bug.cgi?id=846771

the following patch propose a fix for the scenario when lun disk is
being extended and the host gets network exception while trying to
connect the storage domain.
This cause the CDA message not to be set with the host id that was not
manage to connect to the domain.

The solution is to Wrap the VDS calls with try and catch so failedHost list
can be set with the problematic host before throwing an exception.

Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: I3aa40d4671dc99c2126c131fda36c25d8ed4826e
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
2 files changed, 23 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/7743/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java
index 467c97b..e384815 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java
@@ -16,6 +16,7 @@
 import org.ovirt.engine.core.common.businessentities.VdsSpmStatus;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
+import org.ovirt.engine.core.common.errors.VdcBLLException;
 import 
org.ovirt.engine.core.common.vdscommands.GetDeviceListVDSCommandParameters;
 import 
org.ovirt.engine.core.common.vdscommands.GetDevicesVisibilityVDSCommandParameters;
 import org.ovirt.engine.core.common.vdscommands.VDSCommandType;
@@ -126,8 +127,7 @@
 
             // try to connect vds to luns and getDeviceList in order to 
refresh them
             for (LUNs lun : luns) {
-                if 
(!StorageHelperDirector.getInstance().getItem(getStorageDomain().getstorage_type())
-                        .ConnectStorageToLunByVdsId(getStorageDomain(), 
vds.getId(), lun, Guid.Empty)) {
+                if (!connectedStorageToLunByVdsId(vds, lun)) {
                     log.errorFormat("Could not connect host {0} to lun {1}", 
vds.getvds_name(), lun.getLUN_id());
                     setVds(vds);
                     
((ConnectAllHostsToLunCommandReturnValue)getReturnValue()).setFailedVds(vds);
@@ -162,13 +162,28 @@
         return new Pair<Boolean, Map<String, List<Guid>>>(Boolean.TRUE, 
resultMap);
     }
 
+    private boolean connectedStorageToLunByVdsId(VDS vds, LUNs lun) {
+        try {
+            return StorageHelperDirector.getInstance()
+                    .getItem(getStorageDomain().getstorage_type())
+                    .ConnectStorageToLunByVdsId(getStorageDomain(), 
vds.getId(), lun, Guid.Empty);
+        } catch (VdcBLLException e) {
+            ((ConnectAllHostsToLunCommandReturnValue) 
getReturnValue()).setFailedVds(vds);
+            throw e;
+        }
+    }
 
     @SuppressWarnings("unchecked")
     private List<LUNs> getHostLuns(VDS vds) {
-        return (List<LUNs>) runVdsCommand(
-                VDSCommandType.GetDeviceList,
-                new GetDeviceListVDSCommandParameters(vds.getId(),
-                        
getStorageDomain().getstorage_type())).getReturnValue();
+        try {
+            return (List<LUNs>) runVdsCommand(
+                    VDSCommandType.GetDeviceList,
+                    new GetDeviceListVDSCommandParameters(vds.getId(),
+                            
getStorageDomain().getstorage_type())).getReturnValue();
+        } catch (VdcBLLException e) {
+            ((ConnectAllHostsToLunCommandReturnValue) 
getReturnValue()).setFailedVds(vds);
+            throw e;
+        }
     }
 
     /**
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
index f32e197..5e650d2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ExtendSANStorageDomainCommand.java
@@ -61,10 +61,8 @@
                     
getReturnValue().getCanDoActionMessages().add(String.format("$hostName %1s",
                             connectResult.getFailedVds().getvds_name()));
                 }
-                if (connectResult.getFailedLun() != null) {
-                    
getReturnValue().getCanDoActionMessages().add(String.format("$lun %1s",
-                            connectResult.getFailedLun().getLUN_id()));
-                }
+                String lunId = connectResult.getFailedLun() != null ? 
connectResult.getFailedLun().getLUN_id() : "";
+                
getReturnValue().getCanDoActionMessages().add(String.format("$lun %1s", lunId));
                 returnValue = false;
             } else {
                 // use luns list from connect command


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

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

Reply via email to