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/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
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
7 files changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/96/22696/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 16ee97e..a421240 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;
@@ -123,10 +124,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 d3b7543..dd6212c 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
@@ -829,6 +829,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 9c8b34f..d358ed6 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -1042,6 +1042,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.
 POWER_MANAGEMENT_ACTION_ON_ENTITY_ALREADY_IN_PROGRESS=Cannot perform 
${action}. Another power management action is already in progress.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 94ef9e7..d5e4794 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -2750,6 +2750,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Alignment scan of a disk 
attached to a running VM is only supported with RAW virtual disks.")
     String ERROR_CANNOT_RUN_ALIGNMENT_SCAN_VM_IS_RUNNING();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Alignment scan is only 
supported for disks located on block storage domains.")
+    String ACTION_TYPE_FAILED_ALIGNMENT_SCAN_STORAGE_TYPE();
+
     @DefaultStringValue("Cannot ${action} ${type}. Invalid time zone for given 
OS type.")
     String ACTION_TYPE_FAILED_INVALID_TIMEZONE();
 
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 2520eed..afa13ba 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
@@ -914,6 +914,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.
 POWER_MANAGEMENT_ACTION_ON_ENTITY_ALREADY_IN_PROGRESS=Cannot perform 
${action}. Another power management action is already in progress.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:
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 fdcdf18..00b1856 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
@@ -1015,6 +1015,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.
 POWER_MANAGEMENT_ACTION_ON_ENTITY_ALREADY_IN_PROGRESS=Another power management 
action, ${action}, is already in progress.
 
 SCHEDULING_ALL_HOSTS_FILTERED_OUT=Cannot ${action} ${type}. There is no host 
that satisfies current scheduling constraints. See bellow for details:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7a9505ac16c9dd3cf14b584b8ec7e7292d68e98
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
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