You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/07/05 08:49:42 UTC

[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6527: [KVM] Fix for Revert volume snapshot

DaanHoogland commented on code in PR #6527:
URL: https://github.com/apache/cloudstack/pull/6527#discussion_r913547522


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRevertSnapshotCommandWrapper.java:
##########
@@ -178,19 +178,21 @@ protected void revertVolumeToSnapshot(SnapshotObjectTO snapshotOnPrimaryStorage,
      * and the snapshot path from the primary storage.
      */
     protected Pair<String, SnapshotObjectTO> getSnapshot(SnapshotObjectTO snapshotOnPrimaryStorage, SnapshotObjectTO snapshotOnSecondaryStorage,
-            KVMStoragePool kvmStoragePoolPrimary, KVMStoragePool kvmStoragePoolSecondary){
-        String snapshotPath = snapshotOnPrimaryStorage.getPath();
-
-        if (Files.exists(Paths.get(snapshotPath))) {
-            return new Pair<>(snapshotPath, snapshotOnPrimaryStorage);
+            KVMStoragePool kvmStoragePoolPrimary, KVMStoragePool kvmStoragePoolSecondary) {
+        String snapshotPath = null;
+        if (snapshotOnPrimaryStorage != null) {
+            snapshotPath = snapshotOnPrimaryStorage.getPath();
+            if (Files.exists(Paths.get(snapshotPath))) {
+                return new Pair<>(snapshotPath, snapshotOnPrimaryStorage);
+            }
         }
 
         if (kvmStoragePoolSecondary == null) {
             throw new CloudRuntimeException(String.format("Snapshot [%s] does not exists on secondary storage, unable to revert volume [%s] to it.",
                     snapshotOnSecondaryStorage, snapshotOnSecondaryStorage.getVolume()));
         }
 
-        s_logger.trace(String.format("Snapshot [%s] does not exists on primary storage [%s], searching snapshot [%s] on secondary storage [%s].", snapshotOnPrimaryStorage,
+        s_logger.trace(String.format("Snapshot does not exists on primary storage [%s], searching snapshot [%s] on secondary storage [%s].",
                 kvmStoragePoolPrimary, snapshotOnSecondaryStorage, kvmStoragePoolSecondary));

Review Comment:
   ```suggestion
           if (s_logger.isTraceEnabled()) {
               s_logger.trace(String.format("Snapshot does not exists on primary storage [%s], searching snapshot [%s] on secondary storage [%s].",
                       kvmStoragePoolPrimary, snapshotOnSecondaryStorage, kvmStoragePoolSecondary));
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org