Shubhendu Tripathi has uploaded a new change for review.

Change subject: gluster: Corrected geo-rep case of volume snapshot creation
......................................................................

gluster: Corrected geo-rep case of volume snapshot creation

While creating gluster volume snapshot for a geo-replicated
volume, we try to pause the geo-rep session and then create
snapshot for the slave volume first. The pause of the slave
volume should be done only if geo-rep session is not in
one of the states from CREATED, PAUSED or STOPPED.
Modified the code accordingly.

Change-Id: Iaefc24c83168ce53960c9f90597a43d5030f7212
Bug-Url: https://bugzilla.redhat.com/1224902
Signed-off-by: Shubhendu Tripathi <shtri...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java
2 files changed, 45 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/41491/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java
index 1a36bc7..67f8422 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/CreateGlusterVolumeSnapshotCommand.java
@@ -59,64 +59,66 @@
     private boolean pauseAndCreateSnapshotForGeoRepSessions() {
         if (georepSessions != null && georepSessions.size() > 0) {
             for (GlusterGeoRepSession session : georepSessions) {
-                if (session.getStatus() != GeoRepSessionStatus.PAUSED) {
-                    final GlusterVolumeEntity slaveVolume =
-                            
getDbFacade().getGlusterVolumeDao().getById(session.getSlaveVolumeId());
+                final GlusterVolumeEntity slaveVolume =
+                        
getDbFacade().getGlusterVolumeDao().getById(session.getSlaveVolumeId());
 
-                    if (slaveVolume == null) {
-                        // Continue to other geo-rep sessions and pause them 
for snapshot purpose
-                        continue;
-                    }
+                if (slaveVolume == null) {
+                    // Continue to other geo-rep sessions and pause them for 
snapshot purpose
+                    continue;
+                }
 
-                    VDS slaveUpServer = 
ClusterUtils.getInstance().getRandomUpServer(slaveVolume.getClusterId());
-                    if (slaveUpServer == null) {
-                        
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED,
-                                "No up server found in slave cluster of 
geo-rep session");
-                        setSucceeded(false);
-                        return false;
-                    }
+                VDS slaveUpServer = 
ClusterUtils.getInstance().getRandomUpServer(slaveVolume.getClusterId());
+                if (slaveUpServer == null) {
+                    
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED,
+                            "No up server found in slave cluster of geo-rep 
session");
+                    setSucceeded(false);
+                    return false;
+                }
 
-                    // Pause the geo-rep session and create snapshot for 
remote volume
+                // Pause the geo-rep session if required
+                if (!(session.getStatus() == GeoRepSessionStatus.CREATED
+                        || session.getStatus() == GeoRepSessionStatus.PAUSED
+                        || session.getStatus() == 
GeoRepSessionStatus.STOPPED)) {
                     VdcReturnValueBase sessionPauseRetVal = null;
                     try (EngineLock lock = 
acquireEngineLock(slaveVolume.getId(), LockingGroup.GLUSTER_SNAPSHOT)) {
                         sessionPauseRetVal =
                                 
runInternalAction(VdcActionType.PauseGlusterVolumeGeoRepSession,
-                                        new 
GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
+                                        new 
GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(),
+                                                session.getId()));
                     }
                     if (sessionPauseRetVal != null && 
!sessionPauseRetVal.getSucceeded()) {
                         
handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_PAUSE_FAILED,
                                 sessionPauseRetVal.getExecuteFailedMessages());
                         setSucceeded(false);
                         return false;
-                    } else {
-                        // Create snapshot for slave volume
-                        VDSReturnValue snapCreationRetVal =
-                                
runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot,
-                                        new 
CreateGlusterVolumeSnapshotVDSParameters(slaveUpServer.getId(),
-                                                session.getSlaveVolumeName(),
-                                                snapshot.getSnapshotName(),
-                                                snapshot.getDescription(),
-                                                force));
-                        if (!snapCreationRetVal.getSucceeded()) {
-                            
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED,
-                                    
snapCreationRetVal.getVdsError().getMessage());
+                    }
+                }
+
+                // Create snapshot for slave volume
+                VDSReturnValue snapCreationRetVal =
+                        
runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot,
+                                new 
CreateGlusterVolumeSnapshotVDSParameters(slaveUpServer.getId(),
+                                        session.getSlaveVolumeName(),
+                                        snapshot.getSnapshotName(),
+                                        snapshot.getDescription(),
+                                        force));
+                if (!snapCreationRetVal.getSucceeded()) {
+                    
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED,
+                            snapCreationRetVal.getVdsError().getMessage());
                             setSucceeded(false);
                             return false;
-                        } else {
-                            // Persist the snapshot details
-                            GlusterVolumeSnapshotEntity slaveVolumeSnapshot =
-                                    (GlusterVolumeSnapshotEntity) 
snapCreationRetVal.getReturnValue();
-                            
slaveVolumeSnapshot.setClusterId(slaveVolume.getClusterId());
-                            
slaveVolumeSnapshot.setVolumeId(slaveVolume.getId());
-                            
slaveVolumeSnapshot.setDescription(snapshot.getDescription());
-                            
slaveVolumeSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
-                            
getDbFacade().getGlusterVolumeSnapshotDao().save(slaveVolumeSnapshot);
+                } else {
+                    // Persist the snapshot details
+                    GlusterVolumeSnapshotEntity slaveVolumeSnapshot =
+                            (GlusterVolumeSnapshotEntity) 
snapCreationRetVal.getReturnValue();
+                    
slaveVolumeSnapshot.setClusterId(slaveVolume.getClusterId());
+                    slaveVolumeSnapshot.setVolumeId(slaveVolume.getId());
+                    
slaveVolumeSnapshot.setDescription(snapshot.getDescription());
+                    
slaveVolumeSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
+                    
getDbFacade().getGlusterVolumeSnapshotDao().save(slaveVolumeSnapshot);
 
-                            // check if the snapshot soft limit reached now 
for the volume and alert
-                            
getGlusterUtil().alertVolumeSnapshotSoftLimitReached(slaveVolume);
-
-                        }
-                    }
+                    // check if the snapshot soft limit reached now for the 
volume and alert
+                    
getGlusterUtil().alertVolumeSnapshotSoftLimitReached(slaveVolume);
                 }
             }
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java
index 727555e..7eb55b3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/RestoreGlusterVolumeSnapshotCommand.java
@@ -217,7 +217,7 @@
             @Override
             public Boolean runInTransaction() {
                 if (georepSessions != null) {
-                    // Pause the geo-replication session
+                    // Stop the geo-replication session
                     if (!stopGeoReplicationSessions(georepSessions)) {
                         return false;
                     }


-- 
To view, visit https://gerrit.ovirt.org/41491
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to