The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2699
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) === Closes #2698 Signed-off-by: Stéphane Graber <[email protected]>
From eaf33a3d1f4bc675da0746c7da8bfa31583dec04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <[email protected]> Date: Wed, 7 Dec 2016 01:29:17 +0100 Subject: [PATCH] Properly validate daemon keys on unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #2698 Signed-off-by: Stéphane Graber <[email protected]> --- lxd/daemon_config.go | 11 ++++++++++- lxd/storage_zfs.go | 18 +++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go index 5af70ad..3a1ec33 100644 --- a/lxd/daemon_config.go +++ b/lxd/daemon_config.go @@ -49,8 +49,17 @@ func (k *daemonConfigKey) name() string { } func (k *daemonConfigKey) Validate(d *Daemon, value string) error { - // No need to validate when unsetting + // Handle unsetting if value == "" { + value = k.defaultValue + + if k.validator != nil { + err := k.validator(d, k.name(), value) + if err != nil { + return err + } + } + return nil } diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go index 6e12f31..022c42b 100644 --- a/lxd/storage_zfs.go +++ b/lxd/storage_zfs.go @@ -1217,17 +1217,17 @@ func storageZFSValidatePoolName(d *Daemon, key string, value string) error { if err != nil { return fmt.Errorf("Invalid ZFS pool: %v", err) } - } - // Confirm that the new pool is empty - s.zfsPool = value - subvols, err := s.zfsListSubvolumes("") - if err != nil { - return err - } + // Confirm that the new pool is empty + s.zfsPool = value + subvols, err := s.zfsListSubvolumes("") + if err != nil { + return err + } - if len(subvols) > 0 { - return fmt.Errorf("Provided ZFS pool (or dataset) isn't empty") + if len(subvols) > 0 { + return fmt.Errorf("Provided ZFS pool (or dataset) isn't empty") + } } // Confirm the old pool isn't in use anymore
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
