The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/6635
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) === When `init` was modified to call `d.load()` back in https://github.com/lxc/lxd/commit/de19b81a3a53379e5d2bcb4a255c1bbd2e8506cc the intention was that if a driver needed to define it's own `load()` function then it would override the common one. However this isn't working as designed, and instead, because inside `driverCommon.load()` `d` is always of type `driverCommon` it is always calling the common `load` function which does nothing. This change pushes the call to the driver specific `load` function to the main driver `Load()` function where the type of the driver is the interface rather than the common driver. This will allow the cephfs `load()` and future driver's to work correctly.
From 0a3a27dcb12bd53206309a9091db749cb48bc947 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Tue, 17 Dec 2019 11:01:05 +0000 Subject: [PATCH 1/3] lxd/storage/drivers/interface: Changes load() definition as no longer returns error Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lxd/storage/drivers/interface.go b/lxd/storage/drivers/interface.go index c5f7d063ec..9dfed58b15 100644 --- a/lxd/storage/drivers/interface.go +++ b/lxd/storage/drivers/interface.go @@ -14,7 +14,7 @@ import ( type driver interface { Driver - init(state *state.State, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonRulesFunc func(vol Volume) map[string]func(string) error) error + init(state *state.State, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonRulesFunc func(vol Volume) map[string]func(string) error) load() error } From 7d9ce9ddc2ada0c51d2b60024632b7d1bc9d0ee6 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Tue, 17 Dec 2019 11:00:10 +0000 Subject: [PATCH 2/3] lxd/storage/drivers/common: Removes calling driver's load() func from init() This was always calling the common driver's load() function, not the specific driver's load() function as intended. Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/driver_common.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lxd/storage/drivers/driver_common.go b/lxd/storage/drivers/driver_common.go index 591577f5dd..655173fc0e 100644 --- a/lxd/storage/drivers/driver_common.go +++ b/lxd/storage/drivers/driver_common.go @@ -24,15 +24,13 @@ type common struct { logger logger.Logger } -func (d *common) init(state *state.State, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonVolRulesFunc func(vol Volume) map[string]func(string) error) error { +func (d *common) init(state *state.State, name string, config map[string]string, logger logger.Logger, volIDFunc func(volType VolumeType, volName string) (int64, error), commonVolRulesFunc func(vol Volume) map[string]func(string) error) { d.name = name d.config = config d.getVolID = volIDFunc d.getCommonVolumeRules = commonVolRulesFunc d.state = state d.logger = logger - - return d.load() } func (d *common) load() error { From 742fd545f31de55f6f0cfbaf92a24d8ea9e84d32 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Tue, 17 Dec 2019 10:59:47 +0000 Subject: [PATCH 3/3] lxd/storage/drivers/load: Calls driver's load() function from main loader Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- lxd/storage/drivers/load.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lxd/storage/drivers/load.go b/lxd/storage/drivers/load.go index 974dd17699..086d66544b 100644 --- a/lxd/storage/drivers/load.go +++ b/lxd/storage/drivers/load.go @@ -19,7 +19,9 @@ func Load(state *state.State, driverName string, name string, config map[string] } d := driverFunc() - err := d.init(state, name, config, logger, volIDFunc, commonVolRulesFunc) + d.init(state, name, config, logger, volIDFunc, commonVolRulesFunc) + + err := d.load() if err != nil { return nil, err }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel