From fdcd58a794d926495eade54c5221609af50ea51b Mon Sep 17 00:00:00 2001 From: Humble Chirammal Date: Wed, 3 Oct 2018 10:16:41 +0530 Subject: [PATCH] Add `log-level` mount option support for glusterfs plugin The glusterfs plugin/driver set log-level to ERROR by default while mounting glusterfs shares. However at times, its required to supply other log-level options like INFO, TRACE..etc. This patch enables the support to provide other log-level values from storageclass. Additional Ref# https://docs.gluster.org/en/v3/Administrator%20Guide/Setting%20Up%20Clients/ Signed-off-by: Humble Chirammal --- pkg/volume/glusterfs/glusterfs.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/volume/glusterfs/glusterfs.go b/pkg/volume/glusterfs/glusterfs.go index 39b83a2f376..9b6c7564428 100644 --- a/pkg/volume/glusterfs/glusterfs.go +++ b/pkg/volume/glusterfs/glusterfs.go @@ -290,6 +290,7 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { var errs error options := []string{} hasLogFile := false + hasLogLevel := false log := "" if b.readOnly { @@ -297,13 +298,19 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { } - // Check logfile has been provided by user, if provided, use that as the log file. + // Check for log-file,log-level options existence in user supplied mount options, if provided, use those. for _, userOpt := range b.mountOptions { - if dstrings.HasPrefix(userOpt, "log-file") { + + switch { + case dstrings.HasPrefix(userOpt, "log-file"): glog.V(4).Infof("log-file mount option has provided") hasLogFile = true - break + + case dstrings.HasPrefix(userOpt, "log-level"): + glog.V(4).Infof("log-level mount option has provided") + hasLogLevel = true } + } // If logfile has not been provided, create driver specific log file. @@ -324,7 +331,9 @@ func (b *glusterfsMounter) setUpAtInternal(dir string) error { } - options = append(options, "log-level=ERROR") + if !hasLogLevel { + options = append(options, "log-level=ERROR") + } var addrlist []string if b.hosts == nil {