The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7832

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Avoids wiping out the parent volume's volatile shift config and causing a subsequent additional shift on next usage.

Fixes #7831

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
From a4ac1148607aa6a39d6b73cacc751e2dae937b3b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@canonical.com>
Date: Tue, 1 Sep 2020 17:48:01 +0100
Subject: [PATCH] lxd/storage/volumes: Only apply config changes when restoring
 snapshot if non-nil config is supplied

Fixes #7831

Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com>
---
 lxd/storage_volumes.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lxd/storage_volumes.go b/lxd/storage_volumes.go
index ba15bd80bf..f00d210fbb 100644
--- a/lxd/storage_volumes.go
+++ b/lxd/storage_volumes.go
@@ -968,9 +968,13 @@ func storagePoolVolumeTypePut(d *Daemon, r *http.Request, 
volumeTypeName string)
                }
 
                // Handle custom volume update requests.
-               err = pool.UpdateCustomVolume(projectName, vol.Name, 
req.Description, req.Config, nil)
-               if err != nil {
-                       return response.SmartError(err)
+               // Only apply changes during a snapshot restore if a non-nil 
config is supplied to avoid clearing
+               // the volume's config if only restoring snapshot.
+               if req.Restore != "" && req.Config != nil || req.Restore == "" {
+                       err = pool.UpdateCustomVolume(projectName, vol.Name, 
req.Description, req.Config, nil)
+                       if err != nil {
+                               return response.SmartError(err)
+                       }
                }
        } else if volumeType == db.StoragePoolVolumeTypeContainer || volumeType 
== db.StoragePoolVolumeTypeVM {
                inst, err := instance.LoadByProjectAndName(d.State(), 
projectName, vol.Name)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to