Don't cache exec and mounter in RBD volume plugin

Volume plugin can get a different exec and mounter implementation with every
call, it must not be cached.
This commit is contained in:
Jan Safranek
2017-10-27 13:14:35 +02:00
parent d945927077
commit c718fc2ca7
3 changed files with 15 additions and 13 deletions

View File

@@ -41,14 +41,12 @@ var (
// This is the primary entrypoint for volume plugins.
func ProbeVolumePlugins() []volume.VolumePlugin {
return []volume.VolumePlugin{&rbdPlugin{nil, nil, nil}}
return []volume.VolumePlugin{&rbdPlugin{}}
}
// rbdPlugin implements Volume.VolumePlugin.
type rbdPlugin struct {
host volume.VolumeHost
exec mount.Exec
mounter *mount.SafeFormatAndMount
host volume.VolumeHost
}
var _ volume.VolumePlugin = &rbdPlugin{}
@@ -74,8 +72,6 @@ func getPath(uid types.UID, volName string, host volume.VolumeHost) string {
func (plugin *rbdPlugin) Init(host volume.VolumeHost) error {
plugin.host = host
plugin.exec = host.GetExec(plugin.GetPluginName())
plugin.mounter = volumehelper.NewSafeFormatAndMountFromHost(plugin.GetPluginName(), plugin.host)
return nil
}
@@ -505,8 +501,8 @@ func newRBD(podUID types.UID, volName string, image string, pool string, readOnl
Pool: pool,
ReadOnly: readOnly,
plugin: plugin,
mounter: plugin.mounter,
exec: plugin.exec,
mounter: volumehelper.NewSafeFormatAndMountFromHost(plugin.GetPluginName(), plugin.host),
exec: plugin.host.GetExec(plugin.GetPluginName()),
manager: manager,
MetricsProvider: volume.NewMetricsStatFS(getPath(podUID, volName, plugin.host)),
}