Allon Mureinik has uploaded a new change for review.

Change subject: core: CDA to block disk alignment scan on file SDs
......................................................................

core: CDA to block disk alignment scan on file SDs

The current implementation of disk alignment scanning is useless for
file domains, and fails on NFS storage in particular.

This patch blocks such operations by a canDoAction(), to prevent any
useless calls to VDSM.

Change-Id: Ib7a9505ac16c9dd3cf14b584b8ec7e7292d68e98
Bug-Url: https://bugzilla.redhat.com/1046031
Signed-off-by: Allon Mureinik <amure...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
6 files changed, 20 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/61/22661/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
index 273435b..c87f990 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommand.java
@@ -19,6 +19,7 @@
 import org.ovirt.engine.core.common.businessentities.DiskImage;
 import org.ovirt.engine.core.common.businessentities.ImageStatus;
 import org.ovirt.engine.core.common.businessentities.LunDisk;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
@@ -120,10 +121,15 @@
             return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL);
         }
 
-        if (!validate(new 
StoragePoolValidator(getStoragePoolDao().get(getStoragePoolId())).isUp())) {
+        StoragePool sp = getStoragePoolDao().get(getStoragePoolId());
+        if (!validate(new StoragePoolValidator(sp).isUp())) {
             return false;
         }
 
+        if (!sp.getStorageType().isBlockDomain()) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE);
+        }
+
         return true;
     }
 
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
index e88e625..5578e29 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetDiskAlignmentCommandTest.java
@@ -18,6 +18,7 @@
 import org.ovirt.engine.core.common.businessentities.ImageStatus;
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
+import org.ovirt.engine.core.common.businessentities.StorageType;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
@@ -102,6 +103,7 @@
 
         storagePool = new StoragePool();
         storagePool.setStatus(StoragePoolStatus.Up);
+        storagePool.setStorageType(StorageType.ISCSI);
 
         when(vmDao.getVmsListForDisk(diskId, 
Boolean.FALSE)).thenReturn(Collections.singletonList(vm));
         when(vmDeviceDao.get(vmDeviceId)).thenReturn(vmDevice);
@@ -167,4 +169,11 @@
         CanDoActionTestUtils.runAndAssertCanDoActionFailure(cmd,
                 VdcBllMessages.ACTION_TYPE_FAILED_IMAGE_REPOSITORY_NOT_FOUND);
     }
+
+    @Test
+    public void testCanDoActionStoragePoolFile() {
+        storagePool.setStorageType(StorageType.NFS);
+        CanDoActionTestUtils.runAndAssertCanDoActionFailure(cmd,
+                VdcBllMessages.ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE);
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index fd7125c..8016d0c 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -863,6 +863,7 @@
 
     // Alignment scan
     ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE(ErrorType.NOT_SUPPORTED),
 
     //exteral scheduler
     EXTERNAL_SCHEDULER_FAIL(ErrorType.INTERNAL_ERROR),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 1f13889..04d5d2b 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1076,6 +1076,7 @@
 
 # Alignment scan
 ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING=Cannot ${action} ${type}. 
Alignment scan of a disk attached to a running VM is only supported with RAW 
virtual disks.
+ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE=Cannot ${action} ${type}. 
Alignment scan is only supported for disks located on block Storage Domains.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:
 SCHEDULING_HOST_FILTERED_REASON=The host ${hostName} did not satisfy 
${filterType} filter ${filterName}.
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index 63c2905..ca62881 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -929,6 +929,7 @@
 
 # Alignment scan
 ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING=Cannot ${action} ${type}. 
Alignment scan of a disk attached to a running VM is only supported with RAW 
virtual disks.
+ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE=Cannot ${action} ${type}. 
Alignment scan is only supported for disks located on block Storage Domains.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:
 SCHEDULING_HOST_FILTERED_REASON=The host ${hostName} did not satisfy 
${filterType} filter ${filterName}.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index d656ae3..7ebc7d7 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -1049,6 +1049,7 @@
 
 # Alignment scan
 ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING=Cannot ${action} ${type}. 
Alignment scan of a disk attached to a running VM is only supported with RAW 
virtual disks.
+ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE=Cannot ${action} ${type}. 
Alignment scan is only supported for disks located on block Storage Domains.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:
 SCHEDULING_HOST_FILTERED_REASON=The host ${hostName} did not satisfy 
${filterType} filter ${filterName}.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7a9505ac16c9dd3cf14b584b8ec7e7292d68e98
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amure...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to