Move snapshot check before snapshot revert
@@ -102,9 +102,6 @@ func (m *VolumeManager) RevertSnapshot(snapshotName, volumeName string) error {
if err != nil {
return err
}
- if err := engine.SnapshotRevert(snapshotName); err != nil {
- return err
- }
snapshot, err := engine.SnapshotGet(snapshotName)
if err != nil {
return err
@@ -112,6 +109,9 @@ func (m *VolumeManager) RevertSnapshot(snapshotName, volumeName string) error {
if snapshot == nil {
return fmt.Errorf("not found snapshot '%s', for volume '%s'", snapshotName, volumeName)
}
+ if err := engine.SnapshotRevert(snapshotName); err != nil {
+ return err
+ }
logrus.Debugf("Revert to snapshot %v for volume %v", snapshotName, volumeName)
return nil
}
