Maor Lipchuk has uploaded a new change for review.

Change subject: core:End failed live snapshot with warning.
......................................................................

core:End failed live snapshot with warning.

Engine fails to create Live-Snapshot during power off of VM.
This is since the KVM process might be killed in the middle of the
process and the synchronization between the engine VM and the KVM process in 
the VDSM
are not reliable and could be racy.

The proposed solution is to avoid the rollback of the entire operation,
but instead finish the command with success, and add an appropriate
audit log.
That way will allow the VM to be configured to the new snapshot at
the next run.

Change-Id: I1b7f841d3fa02800fd58590c87d64e31227adfe5
Signed-Off-By: Maor Lipchuk <mlipc...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/870928
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
4 files changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/9390/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
index b52bdf5..7580b1b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CreateAllSnapshotsFromVmCommand.java
@@ -38,6 +38,8 @@
 import org.ovirt.engine.core.compat.TransactionScopeOption;
 import org.ovirt.engine.core.dal.VdcBllMessages;
 import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector;
+import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase;
 import org.ovirt.engine.core.dao.SnapshotDao;
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
 import org.ovirt.engine.core.utils.transaction.TransactionSupport;
@@ -189,17 +191,23 @@
                 }
             });
         } catch (VdcBLLException e) {
-            if (e.getErrorCode() == VdcBllErrors.SNAPSHOT_FAILED) {
-                getParameters().setTaskGroupSuccess(false);
-                log.errorFormat("Wasn't able to live snpashot due to error: 
{0}, rolling back.",
-                        ExceptionUtils.getMessage(e));
-                revertToActiveSnapshot(createdSnapshotId);
-            } else {
+            if (e.getErrorCode() != VdcBllErrors.SNAPSHOT_FAILED) {
                 throw e;
             }
+            handleVdsLiveSnapshotFailure(e);
+
         }
     }
 
+    private void handleVdsLiveSnapshotFailure(VdcBLLException e) {
+        log.warnFormat("Wasn't able to live snpashot due to error: {0}. VM 
will still be configured to the new created snapshot",
+                ExceptionUtils.getMessage(e));
+        AuditLogableBase logable = new AuditLogableBase();
+        logable.AddCustomValue("SnapshotName", getSnapshotName());
+        logable.AddCustomValue("VmName", getVmName());
+        AuditLogDirector.log(logable, 
AuditLogType.USER_CREATE_LIVE_SNAPSHOT_FINISHED_FAILURE);
+    }
+
     /**
      * Return the given snapshot ID's snapshot to be the active snapshot. The 
snapshot with the given ID is removed
      * in the process.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index e3f23d4..6c165ce 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -243,6 +243,7 @@
     USER_CREATE_SNAPSHOT(45),
     USER_CREATE_SNAPSHOT_FINISHED_SUCCESS(68),
     USER_CREATE_SNAPSHOT_FINISHED_FAILURE(69),
+    USER_CREATE_LIVE_SNAPSHOT_FINISHED_FAILURE(170),
     USER_FAILED_CREATE_SNAPSHOT(117),
     USER_REMOVE_SNAPSHOT(342),
     USER_FAILED_REMOVE_SNAPSHOT(343),
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 2119afe..36fbf14 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -505,6 +505,7 @@
         mSeverities.put(AuditLogType.USER_CREATE_SNAPSHOT, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.USER_CREATE_SNAPSHOT_FINISHED_SUCCESS, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.USER_CREATE_SNAPSHOT_FINISHED_FAILURE, 
AuditLogSeverity.ERROR);
+        
mSeverities.put(AuditLogType.USER_CREATE_LIVE_SNAPSHOT_FINISHED_FAILURE, 
AuditLogSeverity.WARNING);
         mSeverities.put(AuditLogType.USER_FAILED_CREATE_SNAPSHOT, 
AuditLogSeverity.ERROR);
         mSeverities.put(AuditLogType.USER_REMOVE_SNAPSHOT, 
AuditLogSeverity.NORMAL);
         mSeverities.put(AuditLogType.USER_REMOVE_SNAPSHOT_FINISHED_SUCCESS, 
AuditLogSeverity.NORMAL);
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 9c357de..7e9bc8c 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -38,6 +38,7 @@
 USER_CREATE_SNAPSHOT=Snapshot ${SnapshotName} creation for VM ${VmName} was 
initiated by ${UserName}.
 USER_CREATE_SNAPSHOT_FINISHED_SUCCESS=Snapshot ${SnapshotName} creation for VM 
${VmName} has been completed.
 USER_CREATE_SNAPSHOT_FINISHED_FAILURE=Failed to complete Snapshot 
${SnapshotName} creation for VM ${VmName}.
+USER_CREATE_LIVE_SNAPSHOT_FINISHED_FAILURE=Failed to configured VM ${VmName} 
with Live-Snapshot ${SnapshotName}. VM restart is recommended.
 USER_REMOVE_SNAPSHOT=Snapshot ${SnapshotName} deletion on VM ${VmName} was 
initiated by ${UserName}.
 USER_REMOVE_SNAPSHOT_FINISHED_SUCCESS=Snapshot ${SnapshotName} deletion on VM 
${VmName} has been completed.
 USER_REMOVE_SNAPSHOT_FINISHED_FAILURE=Failed to complete Snapshot 
${SnapshotName} deletion on VM ${VmName}.


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

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

Reply via email to